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

Stefan Roesch
2022-05-20T18:32:12Z

On 5/19/22 1:32 AM, Christoph Hellwig wrote:
>> --- 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.
>

Will change the name to mapping.

>> 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;
>

I introduced the BDP_ASYNC define and used the above code. I also wired it
accordingly in balance_dirty_pages().