summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2020-06-24 07:23:51 +0800
committerDavid Sterba <dsterba@suse.com>2020-07-27 12:55:28 +0200
commite4ecaf90bc13e2a9c351d5cd86d4094844d7d7bd (patch)
treeeea750e132b11aab005d97b79e4e7dc1095e86ac /fs/btrfs/file.c
parent6d4572a9d71d5fc2affee0258d8582d39859188c (diff)
downloadlinux-stable-e4ecaf90bc13e2a9c351d5cd86d4094844d7d7bd.tar.gz
linux-stable-e4ecaf90bc13e2a9c351d5cd86d4094844d7d7bd.tar.bz2
linux-stable-e4ecaf90bc13e2a9c351d5cd86d4094844d7d7bd.zip
btrfs: add comments for btrfs_check_can_nocow() and can_nocow_extent()
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. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 7aa184493aea..b750000b438a 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1533,6 +1533,27 @@ 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)
+ *
+ * @pos: File offset
+ * @write_bytes: The length to write, will be updated to the nocow writeable
+ * range
+ * @nowait: Whether this function could sleep
+ *
+ * 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
+ * 0 if we can't do nocow write
+ * -EAGAIN if we can't get the needed lock or there are ordered extents
+ * for * (nowait == true) case
+ * <0 if other error happened
+ *
+ * NOTE: For wait (nowait == false) calls, callers need to release the drew
+ * write lock of inode->root->snapshot_lock when return value > 0.
+ */
int btrfs_check_can_nocow(struct btrfs_inode *inode, loff_t pos,
size_t *write_bytes, bool nowait)
{