It turns out that 2021 was a pretty good year to be an American farmer.

After struggling through extreme weather, a trade war and tepid demand in recent years, things started to turn around this season as Chinese buying roared back.

What's more, crops proved resilient against bouts of dryness that hit some parts of the Midwest, and analysts surveyed by Bloomberg expect the U.S. Department of Agriculture to lift its estimates for domestic corn and soybean stockpiles in a key report due Tuesday at noon in Washington.

Bumper production on the heels of record corn demand from China means farmers are finally reaping profits from what they're growing and not having to rely as much on government subsidies, like those distributed by the Trump administration during the trade war. Bigger crops would also be welcome news to consumers that are struggling with higher grocery bills.

Still, it's unclear how long the good times will last. Energy and fertilizer costs are going up, signaling thinner margins ahead. And meanwhile, corn and soybean prices are both down about 25% from this year's peak in May.

But for farmers who managed to lock in sales at the start of the summer, this season is a welcome turnaround. U.S. farm income from crops is expected to jump 20% to $230.1 billion in 2021, the second-highest ever, trailing the record set in 2012, according to USDA estimates.

Even after dry conditions hit Iowa farmer Zach Egesdal's fields, his crops "produced better than we thought with the limited moisture," he said.

"We've sold more than we have in the last few years out of the field for both corn and soybeans," Egesdal said in a phone interview. "We were able to lock in a profit and made more sales."

Rising costs and uncertainty over the market means farmers like Pat Swanson from Iowa are already locking in prices for next year's harvest.

"All of our inputs for next year are going to be significantly higher than what they were this past year," she said.