btrfs: Streamline code in run_delalloc_nocow
diff mbox series

Message ID 20190822142523.1425-1-nborisov@suse.com
State New
Headers show
Series
  • btrfs: Streamline code in run_delalloc_nocow
Related show

Commit Message

Nikolay Borisov Aug. 22, 2019, 2:25 p.m. UTC
Add a comment explaining why we keep the BUG also use the already read
and cached value of extent ram bytes stored in 'ram_bytes'.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/inode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

David Sterba Aug. 23, 2019, 5:27 p.m. UTC | #1
On Thu, Aug 22, 2019 at 05:25:23PM +0300, Nikolay Borisov wrote:
> Add a comment explaining why we keep the BUG also use the already read
> and cached value of extent ram bytes stored in 'ram_bytes'.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Added to misc-next, thanks.

Patch
diff mbox series

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 6cb22d82e6aa..161439122a29 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1503,16 +1503,15 @@  static noinline int run_delalloc_nocow(struct inode *inode,
 				goto out_check;
 			nocow = true;
 		} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
-			extent_end = found_key.offset +
-				btrfs_file_extent_ram_bytes(leaf, fi);
-			extent_end = ALIGN(extent_end,
-					   fs_info->sectorsize);
+			extent_end = found_key.offset + ram_bytes;
+			extent_end = ALIGN(extent_end, fs_info->sectorsize);
 			/* Skip extents outside of our requested range */
 			if (extent_end <= start) {
 				path->slots[0]++;
 				goto next_slot;
 			}
 		} else {
+			/* If this triggers then we have a memory corruption */
 			BUG();
 		}
 out_check: