summaryrefslogtreecommitdiff
path: root/fs/bcachefs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-07-09 14:18:28 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:06 -0400
commit07f293c8630d5bdae1615e6add90c76fed333d20 (patch)
tree294c39f019977e99c421856897199187dd4af794 /fs/bcachefs
parentca630f1d3767c20026b33ba1603017e5c8e9da5a (diff)
bcachefs: bch2_xattr_set() now updates ctime
Fixes fstests generic/728 Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r--fs/bcachefs/fs.h2
-rw-r--r--fs/bcachefs/xattr.c31
-rw-r--r--fs/bcachefs/xattr.h2
3 files changed, 22 insertions, 13 deletions
diff --git a/fs/bcachefs/fs.h b/fs/bcachefs/fs.h
index 2e63cb6603bd..6170d214d648 100644
--- a/fs/bcachefs/fs.h
+++ b/fs/bcachefs/fs.h
@@ -196,6 +196,8 @@ int bch2_vfs_init(void);
#else
+#define bch2_inode_update_after_write(_trans, _inode, _inode_u, _fields) do {} while (0)
+
static inline void bch2_evict_subvolume_inodes(struct bch_fs *c,
snapshot_id_list *s) {}
static inline void bch2_vfs_exit(void) {}
diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
index 43904c0ec9ba..70f78006daf2 100644
--- a/fs/bcachefs/xattr.c
+++ b/fs/bcachefs/xattr.c
@@ -167,23 +167,22 @@ err1:
}
int bch2_xattr_set(struct btree_trans *trans, subvol_inum inum,
+ struct bch_inode_unpacked *inode_u,
const struct bch_hash_info *hash_info,
const char *name, const void *value, size_t size,
int type, int flags)
{
+ struct bch_fs *c = trans->c;
struct btree_iter inode_iter = { NULL };
- struct bch_inode_unpacked inode_u;
int ret;
- /*
- * We need to do an inode update so that bi_journal_sync gets updated
- * and fsync works:
- *
- * Perhaps we should be updating bi_mtime too?
- */
+ ret = bch2_inode_peek(trans, &inode_iter, inode_u, inum, BTREE_ITER_INTENT);
+ if (ret)
+ return ret;
- ret = bch2_inode_peek(trans, &inode_iter, &inode_u, inum, BTREE_ITER_INTENT) ?:
- bch2_inode_write(trans, &inode_iter, &inode_u);
+ inode_u->bi_ctime = bch2_current_time(c);
+
+ ret = bch2_inode_write(trans, &inode_iter, inode_u);
bch2_trans_iter_exit(trans, &inode_iter);
if (ret)
@@ -373,12 +372,20 @@ static int bch2_xattr_set_handler(const struct xattr_handler *handler,
struct bch_inode_info *inode = to_bch_ei(vinode);
struct bch_fs *c = inode->v.i_sb->s_fs_info;
struct bch_hash_info hash = bch2_hash_info_init(c, &inode->ei_inode);
+ struct bch_inode_unpacked inode_u;
+ struct btree_trans trans;
int ret;
- ret = bch2_trans_do(c, NULL, NULL, 0,
- bch2_xattr_set(&trans, inode_inum(inode), &hash,
- name, value, size,
+ bch2_trans_init(&trans, c, 0, 0);
+
+ ret = commit_do(&trans, NULL, NULL, 0,
+ bch2_xattr_set(&trans, inode_inum(inode), &inode_u,
+ &hash, name, value, size,
handler->flags, flags));
+ if (!ret)
+ bch2_inode_update_after_write(&trans, inode, &inode_u, ATTR_CTIME);
+ bch2_trans_exit(&trans);
+
return bch2_err_class(ret);
}
diff --git a/fs/bcachefs/xattr.h b/fs/bcachefs/xattr.h
index ad568c06e1f8..f5a52e3a6016 100644
--- a/fs/bcachefs/xattr.h
+++ b/fs/bcachefs/xattr.h
@@ -40,7 +40,7 @@ struct bch_inode_info;
/* Exported for cmd_migrate.c in tools: */
int bch2_xattr_set(struct btree_trans *, subvol_inum,
- const struct bch_hash_info *,
+ struct bch_inode_unpacked *, const struct bch_hash_info *,
const char *, const void *, size_t, int, int);
ssize_t bch2_xattr_list(struct dentry *, char *, size_t);