From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e28smtp06.in.ibm.com ([122.248.162.6]:47673 "EHLO e28smtp06.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754298AbaCLOVb (ORCPT ); Wed, 12 Mar 2014 10:21:31 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Mar 2014 19:51:30 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 4727DE003F for ; Wed, 12 Mar 2014 19:55:14 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2CELLwt4718918 for ; Wed, 12 Mar 2014 19:51:21 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s2CELRQO010249 for ; Wed, 12 Mar 2014 19:51:27 +0530 From: Chandan Rajendra To: linux-btrfs@vger.kernel.org Cc: Chandan Rajendra , aneesh.kumar@linux.vnet.ibm.com Subject: [PATCH 3/6] Btrfs: subpagesize-blocksize: Work with extents aligned to blocksize. Date: Wed, 12 Mar 2014 19:50:30 +0530 Message-Id: <1394634033-2528-4-git-send-email-chandan@linux.vnet.ibm.com> In-Reply-To: <1394634033-2528-1-git-send-email-chandan@linux.vnet.ibm.com> References: <1394634033-2528-1-git-send-email-chandan@linux.vnet.ibm.com> Sender: linux-btrfs-owner@vger.kernel.org List-ID: This is a small part of a bigger set of fixes needed to get subpagesize-blocksize to function properly. This patch is required to get 2k blocksize writes to work correctly. Without this patch, In lock_and_cleanup_extent_if_need() two consecutive 2k block writes that map to first and second 2k parts of a 4k page would result in the second 2k write to *clear* out the EXTENT_DELALLOC bit of the first 2k block. Fix this. Signed-off-by: Chandan Rajendra --- fs/btrfs/file.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 006af2f..1aa8fae 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1339,18 +1339,21 @@ fail: static noinline int lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages, size_t num_pages, loff_t pos, + size_t write_bytes, u64 *lockstart, u64 *lockend, struct extent_state **cached_state) { + struct btrfs_root *root = BTRFS_I(inode)->root; u64 start_pos; u64 last_pos; int i; int ret = 0; - start_pos = pos & ~((u64)PAGE_CACHE_SIZE - 1); - last_pos = start_pos + ((u64)num_pages << PAGE_CACHE_SHIFT) - 1; + start_pos = pos & ~((u64)root->sectorsize - 1); + last_pos = start_pos + + ALIGN(pos + write_bytes - start_pos, root->sectorsize) - 1; - if (start_pos < inode->i_size) { + if (start_pos < inode->i_size) { struct btrfs_ordered_extent *ordered; lock_extent_bits(&BTRFS_I(inode)->io_tree, start_pos, last_pos, 0, cached_state); @@ -1536,8 +1539,8 @@ again: break; ret = lock_and_cleanup_extent_if_need(inode, pages, num_pages, - pos, &lockstart, &lockend, - &cached_state); + pos, write_bytes, &lockstart, &lockend, + &cached_state); if (ret < 0) { if (ret == -EAGAIN) goto again; -- 1.8.3.1