Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1370186yba; Tue, 2 Apr 2019 07:40:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrCu+tdl325vUWtvA7brsfp++fAJ43uCCWuY9BL1Y0/mRaplDvFBnlvXZIzN8gEmnInnD2 X-Received: by 2002:aa7:8083:: with SMTP id v3mr52853503pff.135.1554216045216; Tue, 02 Apr 2019 07:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554216045; cv=none; d=google.com; s=arc-20160816; b=Omd40thTQ2RyT6fi11207oUneiHDMWnHI+IZXXC4WdI3/kIDsidhU9T+NbqBBvzMrn A4R/Y2SMBSjSE+dBm8x5MRFuzdKv3SuR5CjYlZ0u0lQwGh1nSS4+DjnkhZR4W8MVLUWK Rx1GljtMy3amXnVehv3Oi3D2yb5eSk2mrTnnGoOSuRAH+vj4ryFTpfHspD/kBqdthvVt iEy2kSPk2rqGMOe/QA119uhrfLEAlbQe47Eq6sFJX3LOtd2/Ztb0mmKYl7pXBR9RbJ2S i+UQqdZIXMUYE4enSD43tZuV67sQjHhdUXYAUaU7TNEBZET4tlfD0sB9XqeOClvvatTx YRzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=IX8k8mhbBTvMVohRlgk9jgprvkgPPAPta6I/lc/ozBg=; b=XqZ7riGu7eQ9+LCDunPfU89lC+M90lN7JjVOr0/i8tx4NOoV4KqT7IjO8V4invGnh/ cv5lPSzEM3NFLa8cBFQwy/AzIVhlxIiRm0oCq4qqGAT5qKrUsBFWczWv6QoUQUiG9WtD lajHIEGD49U+lWuZgIrpAUWU39Sfsklz+HOva0Qa7jnw7M4DDkyuoImVzvSqHLROa9bz J6zuJmjXg9BJTXiLEmXOY6KfTLexqZN/KIeIIvM71FHmt9+QySLDmED5fFQfgtgZvs+6 fkwFYSfq74nXPVlCeMGmSp1eIZkB4xqbwsyy9OqsM+tuD3tWnsRq19Ma7nu0eGW0GC5B y4NQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r63si11640292plb.94.2019.04.02.07.40.30; Tue, 02 Apr 2019 07:40:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731580AbfDBNkP (ORCPT + 99 others); Tue, 2 Apr 2019 09:40:15 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43114 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731413AbfDBNkE (ORCPT ); Tue, 2 Apr 2019 09:40:04 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJdw-0002nu-NC; Tue, 02 Apr 2019 14:40:01 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdv-0004tL-Nk; Tue, 02 Apr 2019 14:39:59 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Chris Mason" , "Miao Xie" , "Yang Dongsheng" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 36/99] Btrfs: fill ->last_trans for delayed inode in btrfs_fill_inode. In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Yang Dongsheng commit 6e17d30bfaf43e04d991392d8484f1c556810c33 upstream. We need to fill inode when we found a node for it in delayed_nodes_tree. But we did not fill the ->last_trans currently, it will cause the test of xfstest/generic/311 fail. Scenario of the 311 is shown as below: Problem: (1). test_fd = open(fname, O_RDWR|O_DIRECT) (2). pwrite(test_fd, buf, 4096, 0) (3). close(test_fd) (4). drop_all_caches() <-------- "echo 3 > /proc/sys/vm/drop_caches" (5). test_fd = open(fname, O_RDWR|O_DIRECT) (6). fsync(test_fd); <-------- we did not get the correct log entry for the file Reason: When we re-open this file in (5), we would find a node in delayed_nodes_tree and fill the inode we are lookup with the information. But the ->last_trans is not filled, then the fsync() will check the ->last_trans and found it's 0 then say this inode is already in our tree which is commited, not recording the extents for it. Fix: This patch fill the ->last_trans properly and set the runtime_flags if needed in this situation. Then we can get the log entries we expected after (6) and generic/311 passed. Signed-off-by: Dongsheng Yang Reviewed-by: Miao Xie Signed-off-by: Chris Mason Signed-off-by: Ben Hutchings --- fs/btrfs/delayed-inode.c | 2 ++ fs/btrfs/inode.c | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -1801,6 +1801,8 @@ int btrfs_fill_inode(struct inode *inode set_nlink(inode, btrfs_stack_inode_nlink(inode_item)); inode_set_bytes(inode, btrfs_stack_inode_nbytes(inode_item)); BTRFS_I(inode)->generation = btrfs_stack_inode_generation(inode_item); + BTRFS_I(inode)->last_trans = btrfs_stack_inode_transid(inode_item); + inode->i_version = btrfs_stack_inode_sequence(inode_item); inode->i_rdev = 0; *rdev = btrfs_stack_inode_rdev(inode_item); --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3511,25 +3511,28 @@ static void btrfs_read_locked_inode(stru BTRFS_I(inode)->generation = btrfs_inode_generation(leaf, inode_item); BTRFS_I(inode)->last_trans = btrfs_inode_transid(leaf, inode_item); + inode->i_version = btrfs_inode_sequence(leaf, inode_item); + inode->i_generation = BTRFS_I(inode)->generation; + inode->i_rdev = 0; + rdev = btrfs_inode_rdev(leaf, inode_item); + + BTRFS_I(inode)->index_cnt = (u64)-1; + BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item); + +cache_index: /* * If we were modified in the current generation and evicted from memory * and then re-read we need to do a full sync since we don't have any * idea about which extents were modified before we were evicted from * cache. + * + * This is required for both inode re-read from disk and delayed inode + * in delayed_nodes_tree. */ if (BTRFS_I(inode)->last_trans == root->fs_info->generation) set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &BTRFS_I(inode)->runtime_flags); - inode->i_version = btrfs_inode_sequence(leaf, inode_item); - inode->i_generation = BTRFS_I(inode)->generation; - inode->i_rdev = 0; - rdev = btrfs_inode_rdev(leaf, inode_item); - - BTRFS_I(inode)->index_cnt = (u64)-1; - BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item); - -cache_index: path->slots[0]++; if (inode->i_nlink != 1 || path->slots[0] >= btrfs_header_nritems(leaf))