From patchwork Wed Mar 12 14:20:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 3818071 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 14BD4BF540 for ; Wed, 12 Mar 2014 14:21:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30B2E202A7 for ; Wed, 12 Mar 2014 14:21:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F2E02027D for ; Wed, 12 Mar 2014 14:21:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754400AbaCLOVc (ORCPT ); Wed, 12 Mar 2014 10:21:32 -0400 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 d28dlp01.in.ibm.com (9.184.220.126) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Mar 2014 19:51:28 +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 Received: from localhost.in.ibm.com ([9.77.126.47]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s2CEKw7L008421; Wed, 12 Mar 2014 19:51:26 +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> X-Mailer: git-send-email 1.8.3.1 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> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14031214-9574-0000-0000-00000C6516DD Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;