Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
	Qu Wenruo <wqu@suse.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v3 1/3] btrfs: add comments for check_can_nocow() and can_nocow_extent()
Date: Thu, 18 Jun 2020 20:00:22 +0800	[thread overview]
Message-ID: <d3bf5a2e-7216-eaa6-e253-0004353b9e86@gmx.com> (raw)
In-Reply-To: <SN4PR0401MB3598829DD37CA07C8B130F9B9B9B0@SN4PR0401MB3598.namprd04.prod.outlook.com>


[-- Attachment #1.1: Type: text/plain, Size: 3302 bytes --]



On 2020/6/18 下午7:57, Johannes Thumshirn wrote:
> On 18/06/2020 09:50, Qu Wenruo wrote:
>> These two functions have extra conditions that their callers need to
>> meet, and some not-that-common parameters used for return value.
>>
>> So adding some comments may save reviewers some time.
> 
> These comments have a style/formatting similar to kerneldoc, can you make
> them real kerneldoc?

Mind to give an example? It must be a coincident to match some existing
format.

Thanks,
Qu

> 
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>  fs/btrfs/file.c  | 19 +++++++++++++++++++
>>  fs/btrfs/inode.c | 19 +++++++++++++++++--
>>  2 files changed, 36 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
>> index fccf5862cd3e..0e4f57fb2737 100644
>> --- a/fs/btrfs/file.c
>> +++ b/fs/btrfs/file.c
>> @@ -1533,6 +1533,25 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
>>  	return ret;
>>  }
>>  
>> +/*
>> + * Check if we can do nocow write into the range [@pos, @pos + @write_bytes)
>> + *
>> + * This function will flush ordered extents in the range to ensure proper
>> + * nocow checks for (nowait == false) case.
>> + *
>> + * Return >0 and update @write_bytes if we can do nocow write into the range.
>> + * Return 0 if we can't do nocow write.
>> + * Return -EAGAIN if we can't get the needed lock, or for (nowait == true) case,
>> + * there are ordered extents need to be flushed.
>> + * Return <0 for if other error happened.
>> + *
>> + * NOTE: For wait (nowait==false) calls, callers need to release the drew write
>> + * 	 lock of inode->root->snapshot_lock if return value > 0.
>> + *
>> + * @pos:	 File offset of the range
>> + * @write_bytes: The length of the range to check, also contains the nocow
>> + * 		 writable length if we can do nocow write
>> + */
>>  static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos,
>>  				    size_t *write_bytes, bool nowait)
>>  {
>> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
>> index 86f7aa377da9..48e16eae7278 100644
>> --- a/fs/btrfs/inode.c
>> +++ b/fs/btrfs/inode.c
>> @@ -6922,8 +6922,23 @@ static struct extent_map *btrfs_new_extent_direct(struct inode *inode,
>>  }
>>  
>>  /*
>> - * returns 1 when the nocow is safe, < 1 on error, 0 if the
>> - * block must be cow'd
>> + * Check if we can write into [@offset, @offset + @len) of @inode.
>> + *
>> + * Return >0 and update @len if we can do nocow write into [@offset, @offset +
>> + * @len).
>> + * Return 0 if we can't do nocow write.
>> + * Return <0 if error happened.
>> + *
>> + * NOTE: This only checks the file extents, caller is responsible to wait for
>> + *	 any ordered extents.
>> + *
>> + * @offset:	File offset
>> + * @len:	The length to write, will be updated to the nocow writable
>> + * 		range
>> + *
>> + * @orig_start:	(Optional) Return the original file offset of the file extent
>> + * @orig_len:	(Optional) Return the original on-disk length of the file extent
>> + * @ram_bytes:	(Optional) Return the ram_bytes of the file extent
>>   */
>>  noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
>>  			      u64 *orig_start, u64 *orig_block_len,
>>
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-06-18 12:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18  7:49 [PATCH v3 0/3] btrfs: allow btrfs_truncate_block() to fallback to nocow for data space reservation Qu Wenruo
2020-06-18  7:49 ` [PATCH v3 1/3] btrfs: add comments for check_can_nocow() and can_nocow_extent() Qu Wenruo
2020-06-18 11:57   ` Johannes Thumshirn
2020-06-18 12:00     ` Qu Wenruo [this message]
2020-06-18 12:14       ` Johannes Thumshirn
2020-06-18 15:14         ` David Sterba
2020-06-18  7:49 ` [PATCH v3 2/3] btrfs: refactor check_can_nocow() into two variants Qu Wenruo
2020-06-18 12:05   ` Johannes Thumshirn
2020-06-18 12:09     ` Qu Wenruo
2020-06-18 12:16       ` Johannes Thumshirn
2020-06-18 12:35         ` Qu Wenruo
2020-06-18 15:24   ` David Sterba
2020-06-18  7:49 ` [PATCH v3 3/3] btrfs: allow btrfs_truncate_block() to fallback to nocow for data space reservation Qu Wenruo
2020-06-18 15:29 ` [PATCH v3 0/3] " David Sterba

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 \
    --in-reply-to=d3bf5a2e-7216-eaa6-e253-0004353b9e86@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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