Re: [RFC PATCH v3 16/18] iomap: Use balance_dirty_pages_ratelimited_flags in iomap_write_iter

Christoph Hellwig
2022-05-19T08:32:13Z

> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -784,6 +784,7 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
> do {
> struct folio *folio;
> struct page *page;
> + struct address_space *i_mapping = iter->inode->i_mapping;

We tend to call these variables just mapping without the i_ prefix.

> again:
> + if (iter->flags & IOMAP_NOWAIT) {
> + status = balance_dirty_pages_ratelimited_async(i_mapping);

Which also nicely avoids the overly long line here.

> + if (unlikely(status))
> + break;
> + } else {
> + balance_dirty_pages_ratelimited(i_mapping);
> + }

Then again directly calling the underlying helper here would be simpler
to start with.

unsigned int bdp_flags = (iter->flags & IOMAP_NOWAIT) ? BDP_ASYNC : 0;

...

status = balance_dirty_pages_ratelimited_flags(mapping,
bdp_flags);
if (status)
break;