From patchwork Thu Jan 12 14:00:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9513271 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 EAE9860710 for ; Thu, 12 Jan 2017 14:01:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8308286B9 for ; Thu, 12 Jan 2017 14:01:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDA47286DA; Thu, 12 Jan 2017 14:01:39 +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 BED2B286B9 for ; Thu, 12 Jan 2017 14:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751072AbdALOBU (ORCPT ); Thu, 12 Jan 2017 09:01:20 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:36459 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751040AbdALOBR (ORCPT ); Thu, 12 Jan 2017 09:01:17 -0500 Received: by mail-lf0-f67.google.com with SMTP id h65so1925777lfi.3 for ; Thu, 12 Jan 2017 06:01:16 -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=kJFyjGzHzgdDSXyZEnRO20mnqrc5DAsbHrC7XgL0PU8=; b=uBxOAfEGsEBIKgg1R3pOQzyFeFUMfcPbtyYJXfUAHgvpVsbkG6GMrKywFmDnjuCuwc vVQppJ51oznUTkamQCUoGUKXn7ieW35E+sECVj69I6EQbzKO4X+DdwFWthqZg3nGUL0f JHjLqxZ/67eG8PH8cNOcun4eQVrl+nu7wHAMNarC8IFhIeqFVoiwbzpU807cG3AAmYIJ 8O1VE7dHfhuSTd1/xiUXOT0ihv3eMsYtdgSdPSIjkpxKjEmobK67XJebQ1asY+XIl+gk bZrMsmv8vmI7N6zpZtowCmHPq2yXsQAkABjBavgMsyuA1K+Bbr6bTAYy5IW59fmtK89L hBTg== 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=kJFyjGzHzgdDSXyZEnRO20mnqrc5DAsbHrC7XgL0PU8=; b=EsQlnlB6d7VKbKH0aXHP4PMfufPXbMu7z4Ss3sdxcHXTtFNTql9eyR1lrZsZn/1A43 LpYTkD/LdVkf2WNzEMVIhtAJm9eDyLumWVubZehIQu//ns+xYo34WdovIsymu5vu0+sf HEKzUDyTr1IIpP/BkMoG/5DgmDADXnGmClwpdEGoLyZqd9kdzRePsyU2Sn/RcKiusDcA 9VMcjgtuzJUGCPHl/mYNy+a/BnStZ8COzQXO/Qnj63CHwi8AZV9B4URc6hmCpidcW8W6 bdqBy8PvlURu1CYMfcJpCMdIM/Tir8mM7LJiNCg9657dLOWFRFpk4KN/GAqZbRmLhrwo DCTg== X-Gm-Message-State: AIkVDXIJUUwGgVBdtKExvOLMxYcd8yumnU9Z/uD5bAb+J+Na/14SZDJaF5dOKSOibFtBNQ== X-Received: by 10.194.46.132 with SMTP id v4mr8375041wjm.98.1484229675167; Thu, 12 Jan 2017 06:01:15 -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.01.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jan 2017 06:01:14 -0800 (PST) From: Nikolay Borisov To: dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, Nikolay Borisov Subject: [PATCH 18/24] btrfs: Make btrfs_unlink_inode take btrfs_inode Date: Thu, 12 Jan 2017 16:00:44 +0200 Message-Id: <1484229650-24554-19-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/ctree.h | 2 +- fs/btrfs/inode.c | 58 ++++++++++++++++++++++++++--------------------------- fs/btrfs/tree-log.c | 14 ++++++------- 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 6a823719b6c5..06d5e6388b4c 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3119,7 +3119,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry); int btrfs_set_inode_index(struct inode *dir, u64 *index); int btrfs_unlink_inode(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct inode *dir, struct inode *inode, + struct btrfs_inode *dir, struct btrfs_inode *inode, const char *name, int name_len); int btrfs_add_link(struct btrfs_trans_handle *trans, struct inode *parent_inode, struct inode *inode, diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9693f83cfc4b..fd1f34e86580 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3996,7 +3996,7 @@ noinline int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans, */ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct inode *dir, struct inode *inode, + struct btrfs_inode *dir, struct btrfs_inode *inode, const char *name, int name_len) { struct btrfs_fs_info *fs_info = root->fs_info; @@ -4006,8 +4006,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, struct btrfs_dir_item *di; struct btrfs_key key; u64 index; - u64 ino = btrfs_ino(BTRFS_I(inode)); - u64 dir_ino = btrfs_ino(BTRFS_I(dir)); + u64 ino = btrfs_ino(inode); + u64 dir_ino = btrfs_ino(dir); path = btrfs_alloc_path(); if (!path) { @@ -4043,10 +4043,10 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, * that we delay to delete it, and just do this deletion when * we update the inode item. */ - if (BTRFS_I(inode)->dir_index) { - ret = btrfs_delayed_delete_inode_ref(BTRFS_I(inode)); + if (inode->dir_index) { + ret = btrfs_delayed_delete_inode_ref(inode); if (!ret) { - index = BTRFS_I(inode)->dir_index; + index = inode->dir_index; goto skip_backref; } } @@ -4061,21 +4061,19 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, goto err; } skip_backref: - ret = btrfs_delete_delayed_dir_index(trans, fs_info, BTRFS_I(dir), index); + ret = btrfs_delete_delayed_dir_index(trans, fs_info, dir, index); if (ret) { btrfs_abort_transaction(trans, ret); goto err; } - ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, - BTRFS_I(inode), dir_ino); + ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, inode, dir_ino); if (ret != 0 && ret != -ENOENT) { btrfs_abort_transaction(trans, ret); goto err; } - ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len, - BTRFS_I(dir), index); + ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len, dir, index); if (ret == -ENOENT) ret = 0; else if (ret) @@ -4085,26 +4083,26 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, if (ret) goto out; - btrfs_i_size_write(dir, dir->i_size - name_len * 2); - inode_inc_iversion(inode); - inode_inc_iversion(dir); - inode->i_ctime = dir->i_mtime = - dir->i_ctime = current_time(inode); - ret = btrfs_update_inode(trans, root, dir); + btrfs_i_size_write(&dir->vfs_inode, dir->vfs_inode.i_size - name_len * 2); + inode_inc_iversion(&inode->vfs_inode); + inode_inc_iversion(&dir->vfs_inode); + inode->vfs_inode.i_ctime = dir->vfs_inode.i_mtime = + dir->vfs_inode.i_ctime = current_time(&inode->vfs_inode); + ret = btrfs_update_inode(trans, root, &dir->vfs_inode); out: return ret; } int btrfs_unlink_inode(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct inode *dir, struct inode *inode, + struct btrfs_inode *dir, struct btrfs_inode *inode, const char *name, int name_len) { int ret; ret = __btrfs_unlink_inode(trans, root, dir, inode, name, name_len); if (!ret) { - drop_nlink(inode); - ret = btrfs_update_inode(trans, root, inode); + drop_nlink(&inode->vfs_inode); + ret = btrfs_update_inode(trans, root, &inode->vfs_inode); } return ret; } @@ -4144,7 +4142,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) btrfs_record_unlink_dir(trans, BTRFS_I(dir), BTRFS_I(d_inode(dentry)), 0); - ret = btrfs_unlink_inode(trans, root, dir, d_inode(dentry), + ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), BTRFS_I(d_inode(dentry)), dentry->d_name.name, dentry->d_name.len); if (ret) goto out; @@ -4274,7 +4272,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) last_unlink_trans = BTRFS_I(inode)->last_unlink_trans; /* now the directory is empty */ - err = btrfs_unlink_inode(trans, root, dir, d_inode(dentry), + err = btrfs_unlink_inode(trans, root, BTRFS_I(dir), BTRFS_I(d_inode(dentry)), dentry->d_name.name, dentry->d_name.len); if (!err) { btrfs_i_size_write(inode, 0); @@ -9598,8 +9596,8 @@ static int btrfs_rename_exchange(struct inode *old_dir, old_dentry->d_name.name, old_dentry->d_name.len); } else { /* src is an inode */ - ret = __btrfs_unlink_inode(trans, root, old_dir, - old_dentry->d_inode, + ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir), + BTRFS_I(old_dentry->d_inode), old_dentry->d_name.name, old_dentry->d_name.len); if (!ret) @@ -9618,8 +9616,8 @@ static int btrfs_rename_exchange(struct inode *old_dir, new_dentry->d_name.name, new_dentry->d_name.len); } else { /* dest is an inode */ - ret = __btrfs_unlink_inode(trans, dest, new_dir, - new_dentry->d_inode, + ret = __btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir), + BTRFS_I(new_dentry->d_inode), new_dentry->d_name.name, new_dentry->d_name.len); if (!ret) @@ -9874,8 +9872,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, old_dentry->d_name.name, old_dentry->d_name.len); } else { - ret = __btrfs_unlink_inode(trans, root, old_dir, - d_inode(old_dentry), + ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir), + BTRFS_I(d_inode(old_dentry)), old_dentry->d_name.name, old_dentry->d_name.len); if (!ret) @@ -9898,8 +9896,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, new_dentry->d_name.len); BUG_ON(new_inode->i_nlink == 0); } else { - ret = btrfs_unlink_inode(trans, dest, new_dir, - d_inode(new_dentry), + ret = btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir), + BTRFS_I(d_inode(new_dentry)), new_dentry->d_name.name, new_dentry->d_name.len); } diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 94f2e1c705b2..73a7e7b5aadc 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -874,7 +874,7 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans, if (ret) goto out; - ret = btrfs_unlink_inode(trans, root, dir, inode, name, name_len); + ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), BTRFS_I(inode), name, name_len); if (ret) goto out; else @@ -1049,8 +1049,8 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans, inc_nlink(inode); btrfs_release_path(path); - ret = btrfs_unlink_inode(trans, root, dir, - inode, victim_name, + ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), + BTRFS_I(inode), victim_name, victim_name_len); kfree(victim_name); if (ret) @@ -1120,8 +1120,8 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans, btrfs_release_path(path); ret = btrfs_unlink_inode(trans, root, - victim_parent, - inode, + BTRFS_I(victim_parent), + BTRFS_I(inode), victim_name, victim_name_len); if (!ret) @@ -2051,8 +2051,8 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans, } inc_nlink(inode); - ret = btrfs_unlink_inode(trans, root, dir, inode, - name, name_len); + ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), + BTRFS_I(inode), name, name_len); if (!ret) ret = btrfs_run_delayed_items(trans, fs_info); kfree(name);