Commit 19df27a9 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make btrfs_log_inode_parent take btrfs_inode

Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent aefa6115
...@@ -5390,7 +5390,8 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans, ...@@ -5390,7 +5390,8 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
* the last committed transaction * the last committed transaction
*/ */
static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode, struct btrfs_root *root,
struct btrfs_inode *inode,
struct dentry *parent, struct dentry *parent,
const loff_t start, const loff_t start,
const loff_t end, const loff_t end,
...@@ -5404,9 +5405,9 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, ...@@ -5404,9 +5405,9 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
int ret = 0; int ret = 0;
u64 last_committed = fs_info->last_trans_committed; u64 last_committed = fs_info->last_trans_committed;
bool log_dentries = false; bool log_dentries = false;
struct inode *orig_inode = inode; struct btrfs_inode *orig_inode = inode;
sb = inode->i_sb; sb = inode->vfs_inode.i_sb;
if (btrfs_test_opt(fs_info, NOTREELOG)) { if (btrfs_test_opt(fs_info, NOTREELOG)) {
ret = 1; ret = 1;
...@@ -5423,18 +5424,17 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, ...@@ -5423,18 +5424,17 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
goto end_no_trans; goto end_no_trans;
} }
if (root != BTRFS_I(inode)->root || if (root != inode->root || btrfs_root_refs(&root->root_item) == 0) {
btrfs_root_refs(&root->root_item) == 0) {
ret = 1; ret = 1;
goto end_no_trans; goto end_no_trans;
} }
ret = check_parent_dirs_for_sync(trans, BTRFS_I(inode), parent, ret = check_parent_dirs_for_sync(trans, inode, parent, sb,
sb, last_committed); last_committed);
if (ret) if (ret)
goto end_no_trans; goto end_no_trans;
if (btrfs_inode_in_log(BTRFS_I(inode), trans->transid)) { if (btrfs_inode_in_log(inode, trans->transid)) {
ret = BTRFS_NO_LOG_SYNC; ret = BTRFS_NO_LOG_SYNC;
goto end_no_trans; goto end_no_trans;
} }
...@@ -5443,8 +5443,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, ...@@ -5443,8 +5443,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
if (ret) if (ret)
goto end_no_trans; goto end_no_trans;
ret = btrfs_log_inode(trans, root, BTRFS_I(inode), inode_only, ret = btrfs_log_inode(trans, root, inode, inode_only, start, end, ctx);
start, end, ctx);
if (ret) if (ret)
goto end_trans; goto end_trans;
...@@ -5454,14 +5453,14 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, ...@@ -5454,14 +5453,14 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
* we can use the last_unlink_trans field to record renames * we can use the last_unlink_trans field to record renames
* and other fun in this file. * and other fun in this file.
*/ */
if (S_ISREG(inode->i_mode) && if (S_ISREG(inode->vfs_inode.i_mode) &&
BTRFS_I(inode)->generation <= last_committed && inode->generation <= last_committed &&
BTRFS_I(inode)->last_unlink_trans <= last_committed) { inode->last_unlink_trans <= last_committed) {
ret = 0; ret = 0;
goto end_trans; goto end_trans;
} }
if (S_ISDIR(inode->i_mode) && ctx && ctx->log_new_dentries) if (S_ISDIR(inode->vfs_inode.i_mode) && ctx && ctx->log_new_dentries)
log_dentries = true; log_dentries = true;
/* /*
...@@ -5505,8 +5504,8 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, ...@@ -5505,8 +5504,8 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
* but the file inode does not have a matching BTRFS_INODE_REF_KEY item * but the file inode does not have a matching BTRFS_INODE_REF_KEY item
* and has a link count of 2. * and has a link count of 2.
*/ */
if (BTRFS_I(inode)->last_unlink_trans > last_committed) { if (inode->last_unlink_trans > last_committed) {
ret = btrfs_log_all_parents(trans, BTRFS_I(orig_inode), ctx); ret = btrfs_log_all_parents(trans, orig_inode, ctx);
if (ret) if (ret)
goto end_trans; goto end_trans;
} }
...@@ -5515,14 +5514,13 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, ...@@ -5515,14 +5514,13 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
if (!parent || d_really_is_negative(parent) || sb != parent->d_sb) if (!parent || d_really_is_negative(parent) || sb != parent->d_sb)
break; break;
inode = d_inode(parent); inode = BTRFS_I(d_inode(parent));
if (root != BTRFS_I(inode)->root) if (root != inode->root)
break; break;
if (BTRFS_I(inode)->generation > last_committed) { if (inode->generation > last_committed) {
ret = btrfs_log_inode(trans, root, BTRFS_I(inode), ret = btrfs_log_inode(trans, root, inode,
LOG_INODE_EXISTS, LOG_INODE_EXISTS, 0, LLONG_MAX, ctx);
0, LLONG_MAX, ctx);
if (ret) if (ret)
goto end_trans; goto end_trans;
} }
...@@ -5534,7 +5532,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, ...@@ -5534,7 +5532,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
old_parent = parent; old_parent = parent;
} }
if (log_dentries) if (log_dentries)
ret = log_new_dir_dentries(trans, root, BTRFS_I(orig_inode), ctx); ret = log_new_dir_dentries(trans, root, orig_inode, ctx);
else else
ret = 0; ret = 0;
end_trans: end_trans:
...@@ -5566,8 +5564,8 @@ int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans, ...@@ -5566,8 +5564,8 @@ int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans,
struct dentry *parent = dget_parent(dentry); struct dentry *parent = dget_parent(dentry);
int ret; int ret;
ret = btrfs_log_inode_parent(trans, root, d_inode(dentry), parent, ret = btrfs_log_inode_parent(trans, root, BTRFS_I(d_inode(dentry)),
start, end, 0, ctx); parent, start, end, 0, ctx);
dput(parent); dput(parent);
return ret; return ret;
...@@ -5829,7 +5827,7 @@ int btrfs_log_new_name(struct btrfs_trans_handle *trans, ...@@ -5829,7 +5827,7 @@ int btrfs_log_new_name(struct btrfs_trans_handle *trans,
(!old_dir || old_dir->logged_trans <= fs_info->last_trans_committed)) (!old_dir || old_dir->logged_trans <= fs_info->last_trans_committed))
return 0; return 0;
return btrfs_log_inode_parent(trans, root, &inode->vfs_inode, parent, 0, return btrfs_log_inode_parent(trans, root, inode, parent, 0,
LLONG_MAX, 1, NULL); LLONG_MAX, 1, NULL);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment