From patchwork Thu Jan 12 14:00:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9513283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C18F60710 for ; Thu, 12 Jan 2017 14:02:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 586BD286B9 for ; Thu, 12 Jan 2017 14:01:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D5C4286D5; Thu, 12 Jan 2017 14:01:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDAB7286B9 for ; Thu, 12 Jan 2017 14:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750950AbdALOBE (ORCPT ); Thu, 12 Jan 2017 09:01:04 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34004 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750873AbdALOBD (ORCPT ); Thu, 12 Jan 2017 09:01:03 -0500 Received: by mail-wm0-f68.google.com with SMTP id c85so3881065wmi.1 for ; Thu, 12 Jan 2017 06:01:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cb82cikUKP/F2fb7ap3wSRo7FA81+JMHCaWMqWGcEpQ=; b=iZhENAYrZegucxM3YArWd4E0qjnzX5n6yF2ZuG7xF4fO7nDnAkJEyJN+zUXZ2KFeF8 pI84oM3L9UQzp8Kmmyi3VWRY7RLLHde/aBs0Ry75ZiLnuJDOtsbxQePIDt0zeexzBOJu cRLxPlVOYhiTGpe3sDDTNXiDMhreNw70PhPhAQ0kci1PyMzUu2Z4nS+YKpslvqjmszyP 85+ivD+S/mqWYe+zDmRWAdyjVfLeJjv9PRP/WshqHLfJmJQ78Hgk5IbTCPH5Z9Zg6DxO YB4CH3UyCWnE6cGSAQZgw2wVlBcwUl601GervxoRbv2mhCKc216z9rwpQUWeYA4QduHC nItg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cb82cikUKP/F2fb7ap3wSRo7FA81+JMHCaWMqWGcEpQ=; b=EiHuEgQWqqeqXKphiK1i1wrS2nh+G1j6vZBauDVZLx30Ak3OzOzxadQMoTc75BziYB BE9YaE+zIIer6X1Vqf0E+MjbZgzCIa0SCNcn9xOYzNVnLtuRQCziiNHOQ3xckn0wXuC/ mGg23kUiE5PS+aCpMW7e+nglmG4G5YeN7ojKLMspYSxM9S32ECX+fCAsiuajzFOJy7Gt 4jRmvQupWJ2Y91UdrG35Gbbl31TAjUebro//V+4avEGWiMMyEpkdZBT+KaTUzIHHMbUX e2tKMQ+vKSEK7H4fsAJE5ooBuudYUo2rkMFcI5sm0w4suY/e6tFW8hG02HsjqESvHvpT Tr1A== X-Gm-Message-State: AIkVDXLsWnljvX/NF+1ZXSS+bCCROk2RPT9lBS9OP2aNx9T0TZlknxSY5DjCD5FqYmdw/A== X-Received: by 10.28.137.193 with SMTP id l184mr7925104wmd.88.1484229659235; Thu, 12 Jan 2017 06:00:59 -0800 (PST) Received: from fisk.lan (ivokamhome.ddns.nbis.net. [87.120.136.31]) by smtp.gmail.com with ESMTPSA id y145sm725670wmc.17.2017.01.12.06.00.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jan 2017 06:00:58 -0800 (PST) From: Nikolay Borisov To: dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, Nikolay Borisov Subject: [PATCH 04/24] btrfs: Make btrfs_inode_in_log take btrfs_inode Date: Thu, 12 Jan 2017 16:00:30 +0200 Message-Id: <1484229650-24554-5-git-send-email-n.borisov.lkml@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484229650-24554-1-git-send-email-n.borisov.lkml@gmail.com> References: <1484229650-24554-1-git-send-email-n.borisov.lkml@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nikolay Borisov --- fs/btrfs/btrfs_inode.h | 16 +++++++--------- fs/btrfs/file.c | 2 +- fs/btrfs/inode.c | 16 ++++++++-------- fs/btrfs/tree-log.c | 4 ++-- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 4fed080545c6..b2dde0efebc0 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -255,16 +255,14 @@ static inline bool btrfs_is_free_space_inode(struct inode *inode) return false; } -static inline int btrfs_inode_in_log(struct inode *inode, u64 generation) +static inline int btrfs_inode_in_log(struct btrfs_inode *inode, u64 generation) { int ret = 0; - spin_lock(&BTRFS_I(inode)->lock); - if (BTRFS_I(inode)->logged_trans == generation && - BTRFS_I(inode)->last_sub_trans <= - BTRFS_I(inode)->last_log_commit && - BTRFS_I(inode)->last_sub_trans <= - BTRFS_I(inode)->root->last_log_commit) { + spin_lock(&inode->lock); + if (inode->logged_trans == generation && + inode->last_sub_trans <= inode->last_log_commit && + inode->last_sub_trans <= inode->root->last_log_commit) { /* * After a ranged fsync we might have left some extent maps * (that fall outside the fsync's range). So return false @@ -272,10 +270,10 @@ static inline int btrfs_inode_in_log(struct inode *inode, u64 generation) * will be called and process those extent maps. */ smp_mb(); - if (list_empty(&BTRFS_I(inode)->extent_tree.modified_extents)) + if (list_empty(&inode->extent_tree.modified_extents)) ret = 1; } - spin_unlock(&BTRFS_I(inode)->lock); + spin_unlock(&inode->lock); return ret; } diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 0d32f45cef28..149b79b3aaf8 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2062,7 +2062,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) * commit does not start nor waits for ordered extents to complete. */ smp_mb(); - if (btrfs_inode_in_log(inode, fs_info->generation) || + if (btrfs_inode_in_log(BTRFS_I(inode), fs_info->generation) || (full_sync && BTRFS_I(inode)->last_trans <= fs_info->last_trans_committed) || (!btrfs_have_ordered_extents_in_range(inode, start, len) && diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c8e73cf9306f..c2835d0b7098 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9676,11 +9676,11 @@ static int btrfs_rename_exchange(struct inode *old_dir, * allow the tasks to sync it. */ if (ret && (root_log_pinned || dest_log_pinned)) { - if (btrfs_inode_in_log(old_dir, fs_info->generation) || - btrfs_inode_in_log(new_dir, fs_info->generation) || - btrfs_inode_in_log(old_inode, fs_info->generation) || + if (btrfs_inode_in_log(BTRFS_I(old_dir), fs_info->generation) || + btrfs_inode_in_log(BTRFS_I(new_dir), fs_info->generation) || + btrfs_inode_in_log(BTRFS_I(old_inode), fs_info->generation) || (new_inode && - btrfs_inode_in_log(new_inode, fs_info->generation))) + btrfs_inode_in_log(BTRFS_I(new_inode), fs_info->generation))) btrfs_set_log_full_commit(fs_info, trans); if (root_log_pinned) { @@ -9952,11 +9952,11 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, * allow the tasks to sync it. */ if (ret && log_pinned) { - if (btrfs_inode_in_log(old_dir, fs_info->generation) || - btrfs_inode_in_log(new_dir, fs_info->generation) || - btrfs_inode_in_log(old_inode, fs_info->generation) || + if (btrfs_inode_in_log(BTRFS_I(old_dir), fs_info->generation) || + btrfs_inode_in_log(BTRFS_I(new_dir), fs_info->generation) || + btrfs_inode_in_log(BTRFS_I(old_inode), fs_info->generation) || (new_inode && - btrfs_inode_in_log(new_inode, fs_info->generation))) + btrfs_inode_in_log(BTRFS_I(new_inode), fs_info->generation))) btrfs_set_log_full_commit(fs_info, trans); btrfs_end_log_trans(root); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index db787d957b74..806e0ffc9150 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -5230,7 +5230,7 @@ static int log_new_dir_dentries(struct btrfs_trans_handle *trans, goto next_dir_inode; } - if (btrfs_inode_in_log(di_inode, trans->transid)) { + if (btrfs_inode_in_log(BTRFS_I(di_inode), trans->transid)) { iput(di_inode); break; } @@ -5429,7 +5429,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, if (ret) goto end_no_trans; - if (btrfs_inode_in_log(inode, trans->transid)) { + if (btrfs_inode_in_log(BTRFS_I(inode), trans->transid)) { ret = BTRFS_NO_LOG_SYNC; goto end_no_trans; }