public inbox for [email protected]
 help / color / mirror / Atom feed
From: Stefan Roesch <[email protected]>
To: Matthew Wilcox <[email protected]>
Cc: <[email protected]>, <[email protected]>,
	<[email protected]>, <[email protected]>
Subject: Re: [PATCH v1 07/14] fs: Add aop_flags parameter to create_page_buffers()
Date: Wed, 16 Feb 2022 10:30:33 -0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>



On 2/14/22 10:14 AM, Matthew Wilcox wrote:
> On Mon, Feb 14, 2022 at 09:43:56AM -0800, Stefan Roesch wrote:
>> This adds the aop_flags parameter to the create_page_buffers function.
>> When AOP_FLAGS_NOWAIT parameter is set, the atomic allocation flag is
>> set. The AOP_FLAGS_NOWAIT flag is set, when async buffered writes are
>> enabled.
> 
> Why is this better than passing in gfp flags directly?
> 

I don't think that gfp flags are a great fit here. We only want to pass in
a nowait flag and this does not map nicely to a gfp flag. 

Instead of passing in a flag parameter we can also pass in a bool parameter,
however that has its limitations as it can't be extended in the future.

>> Signed-off-by: Stefan Roesch <[email protected]>
>> ---
>>  fs/buffer.c | 28 +++++++++++++++++++++-------
>>  1 file changed, 21 insertions(+), 7 deletions(-)
>>
>> diff --git a/fs/buffer.c b/fs/buffer.c
>> index 948505480b43..5e3067173580 100644
>> --- a/fs/buffer.c
>> +++ b/fs/buffer.c
>> @@ -1682,13 +1682,27 @@ static inline int block_size_bits(unsigned int blocksize)
>>  	return ilog2(blocksize);
>>  }
>>  
>> -static struct buffer_head *create_page_buffers(struct page *page, struct inode *inode, unsigned int b_state)
>> +static struct buffer_head *create_page_buffers(struct page *page,
>> +					struct inode *inode,
>> +					unsigned int b_state,
>> +					unsigned int aop_flags)
>>  {
>>  	BUG_ON(!PageLocked(page));
>>  
>> -	if (!page_has_buffers(page))
>> -		create_empty_buffers(page, 1 << READ_ONCE(inode->i_blkbits),
>> -				     b_state);
>> +	if (!page_has_buffers(page)) {
>> +		gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT;
>> +
>> +		if (aop_flags & AOP_FLAGS_NOWAIT) {
>> +			gfp |= GFP_ATOMIC | __GFP_NOWARN;
>> +			gfp &= ~__GFP_DIRECT_RECLAIM;
>> +		} else {
>> +			gfp |= __GFP_NOFAIL;
>> +		}
>> +
>> +		__create_empty_buffers(page, 1 << READ_ONCE(inode->i_blkbits),
>> +				     b_state, gfp);
>> +	}
>> +
>>  	return page_buffers(page);
>>  }
>>  
>> @@ -1734,7 +1748,7 @@ int __block_write_full_page(struct inode *inode, struct page *page,
>>  	int write_flags = wbc_to_write_flags(wbc);
>>  
>>  	head = create_page_buffers(page, inode,
>> -					(1 << BH_Dirty)|(1 << BH_Uptodate));
>> +					(1 << BH_Dirty)|(1 << BH_Uptodate), 0);
>>  
>>  	/*
>>  	 * Be very careful.  We have no exclusion from __set_page_dirty_buffers
>> @@ -2000,7 +2014,7 @@ int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len,
>>  	BUG_ON(to > PAGE_SIZE);
>>  	BUG_ON(from > to);
>>  
>> -	head = create_page_buffers(&folio->page, inode, 0);
>> +	head = create_page_buffers(&folio->page, inode, 0, flags);
>>  	blocksize = head->b_size;
>>  	bbits = block_size_bits(blocksize);
>>  
>> @@ -2280,7 +2294,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block)
>>  	int nr, i;
>>  	int fully_mapped = 1;
>>  
>> -	head = create_page_buffers(page, inode, 0);
>> +	head = create_page_buffers(page, inode, 0, 0);
>>  	blocksize = head->b_size;
>>  	bbits = block_size_bits(blocksize);
>>  
>> -- 
>> 2.30.2
>>

  reply	other threads:[~2022-02-16 18:31 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 17:43 [PATCH v1 00/14] Support sync buffered writes for io-uring Stefan Roesch
2022-02-14 17:43 ` [PATCH v1 01/14] fs: Add flags parameter to __block_write_begin_int Stefan Roesch
2022-02-14 19:02   ` Matthew Wilcox
2022-02-16 18:31     ` Stefan Roesch
2022-02-16 18:35       ` Matthew Wilcox
2022-02-14 17:43 ` [PATCH v1 02/14] mm: Introduce do_generic_perform_write Stefan Roesch
2022-02-14 19:06   ` Matthew Wilcox
2022-02-14 17:43 ` [PATCH v1 03/14] mm: add noio support in filemap_get_pages Stefan Roesch
2022-02-14 18:08   ` Matthew Wilcox
2022-02-16 18:27     ` Stefan Roesch
2022-02-14 19:33   ` Matthew Wilcox
2022-02-16 18:26     ` Stefan Roesch
2022-02-14 17:43 ` [PATCH v1 04/14] mm: Add support for async buffered writes Stefan Roesch
2022-02-14 19:09   ` Matthew Wilcox
2022-02-14 17:43 ` [PATCH v1 05/14] fs: split off __alloc_page_buffers function Stefan Roesch
2022-02-14 22:46   ` kernel test robot
2022-02-14 23:27   ` kernel test robot
2022-02-15  2:40   ` [RFC PATCH] fs: __alloc_page_buffers() can be static kernel test robot
2022-02-15  2:41   ` [PATCH v1 05/14] fs: split off __alloc_page_buffers function kernel test robot
2022-02-14 17:43 ` [PATCH v1 06/14] fs: split off __create_empty_buffers function Stefan Roesch
2022-02-14 17:43 ` [PATCH v1 07/14] fs: Add aop_flags parameter to create_page_buffers() Stefan Roesch
2022-02-14 18:14   ` Matthew Wilcox
2022-02-16 18:30     ` Stefan Roesch [this message]
2022-02-16 18:34       ` Matthew Wilcox
2022-02-16 18:35         ` Stefan Roesch
2022-02-14 17:43 ` [PATCH v1 08/14] fs: add support for async buffered writes Stefan Roesch
2022-02-14 17:43 ` [PATCH v1 09/14] io_uring: " Stefan Roesch
2022-02-14 17:43 ` [PATCH v1 10/14] io_uring: Add tracepoint for short writes Stefan Roesch
2022-02-14 17:44 ` [PATCH v1 11/14] sched: add new fields to task_struct Stefan Roesch
2022-02-14 17:44 ` [PATCH v1 12/14] mm: support write throttling for async buffered writes Stefan Roesch
2022-02-14 17:44 ` [PATCH v1 13/14] io_uring: " Stefan Roesch
2022-02-14 17:44 ` [PATCH v1 14/14] block: enable async buffered writes for block devices Stefan Roesch
2022-02-15  3:59 ` [PATCH v1 00/14] Support sync buffered writes for io-uring Hao Xu
2022-02-15 17:38   ` Stefan Roesch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox