bcachefs: Add subvolume to ei_inode_info

Filesystem operations generally operate within a subvolume: at the start
of every btree transaction we'll be looking up (and locking) the
subvolume to get the current snapshot ID, which we then use for our
other btree lookups in BTREE_ITER_FILTER_SNAPSHOTS mode.

But inodes don't record what subvolume they're in - they can't, because
if they did we'd have to update every single inode within a subvolume
when taking a snapshot in order to keep that field up to date. So it
needs to be tracked in memory, based on how we got to that inode.

Hence this patch adds a subvolume field to ei_inode_info, and switches
to iget5() so we can index by it in the inode hash table.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet
2021-03-16 01:33:39 -04:00
committed by Kent Overstreet
parent 81ed9ce367
commit 284ae18c1d
3 changed files with 76 additions and 27 deletions

View File

@ -192,7 +192,7 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c,
char *kname = NULL;
struct qstr qstr;
int ret = 0;
u64 inum;
subvol_inum inum = { .subvol = 1 };
kname = kmalloc(BCH_NAME_MAX + 1, GFP_KERNEL);
if (!kname)
@ -206,9 +206,9 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c,
qstr.name = kname;
ret = -ENOENT;
inum = bch2_dirent_lookup(c, src->v.i_ino, &hash,
inum.inum = bch2_dirent_lookup(c, src->v.i_ino, &hash,
&qstr);
if (!inum)
if (!inum.inum)
goto err1;
vinode = bch2_vfs_inode_get(c, inum);