Skip to content

Commit d9f892b

Browse files
committed
reiserfs: rework priv inode handling
Reiserfs is the only filesystem that removes IOP_XATTR without also using a set of dedicated inode operations at the same time that nop all xattr related inode operations. This means we need to have a IOP_XATTR check in vfs_listxattr() instead of just being able to check for ->listxatt() being implemented. Introduce a dedicated set of nop inode operations that are used when IOP_XATTR is removed, allowing us to remove that check from vfs_listxattr(). This in turn allows us to completely decouple POSIX ACLs from IOP_XATTR. Cc: reiserfs-devel@vger.kernel.org Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
1 parent d549b74 commit d9f892b

5 files changed

Lines changed: 59 additions & 15 deletions

File tree

fs/reiserfs/file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,10 @@ const struct inode_operations reiserfs_file_inode_operations = {
261261
.fileattr_get = reiserfs_fileattr_get,
262262
.fileattr_set = reiserfs_fileattr_set,
263263
};
264+
265+
const struct inode_operations reiserfs_priv_file_inode_operations = {
266+
.setattr = reiserfs_setattr,
267+
.permission = reiserfs_permission,
268+
.fileattr_get = reiserfs_fileattr_get,
269+
.fileattr_set = reiserfs_fileattr_set,
270+
};

fs/reiserfs/inode.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,10 +2087,8 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
20872087
* Mark it private if we're creating the privroot
20882088
* or something under it.
20892089
*/
2090-
if (IS_PRIVATE(dir) || dentry == REISERFS_SB(sb)->priv_root) {
2091-
inode->i_flags |= S_PRIVATE;
2092-
inode->i_opflags &= ~IOP_XATTR;
2093-
}
2090+
if (IS_PRIVATE(dir) || dentry == REISERFS_SB(sb)->priv_root)
2091+
reiserfs_init_priv_inode(inode);
20942092

20952093
if (reiserfs_posixacl(inode->i_sb)) {
20962094
reiserfs_write_unlock(inode->i_sb);

fs/reiserfs/namei.c

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,11 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
378378

379379
/*
380380
* Propagate the private flag so we know we're
381-
* in the priv tree. Also clear IOP_XATTR
381+
* in the priv tree. Also clear xattr support
382382
* since we don't have xattrs on xattr files.
383383
*/
384-
if (IS_PRIVATE(dir)) {
385-
inode->i_flags |= S_PRIVATE;
386-
inode->i_opflags &= ~IOP_XATTR;
387-
}
384+
if (IS_PRIVATE(dir))
385+
reiserfs_init_priv_inode(inode);
388386
}
389387
reiserfs_write_unlock(dir->i_sb);
390388
if (retval == IO_ERROR) {
@@ -1649,6 +1647,48 @@ static int reiserfs_rename(struct mnt_idmap *idmap,
16491647
return retval;
16501648
}
16511649

1650+
static const struct inode_operations reiserfs_priv_dir_inode_operations = {
1651+
.create = reiserfs_create,
1652+
.lookup = reiserfs_lookup,
1653+
.link = reiserfs_link,
1654+
.unlink = reiserfs_unlink,
1655+
.symlink = reiserfs_symlink,
1656+
.mkdir = reiserfs_mkdir,
1657+
.rmdir = reiserfs_rmdir,
1658+
.mknod = reiserfs_mknod,
1659+
.rename = reiserfs_rename,
1660+
.setattr = reiserfs_setattr,
1661+
.permission = reiserfs_permission,
1662+
.fileattr_get = reiserfs_fileattr_get,
1663+
.fileattr_set = reiserfs_fileattr_set,
1664+
};
1665+
1666+
static const struct inode_operations reiserfs_priv_symlink_inode_operations = {
1667+
.get_link = page_get_link,
1668+
.setattr = reiserfs_setattr,
1669+
.permission = reiserfs_permission,
1670+
};
1671+
1672+
static const struct inode_operations reiserfs_priv_special_inode_operations = {
1673+
.setattr = reiserfs_setattr,
1674+
.permission = reiserfs_permission,
1675+
};
1676+
1677+
void reiserfs_init_priv_inode(struct inode *inode)
1678+
{
1679+
inode->i_flags |= S_PRIVATE;
1680+
inode->i_opflags &= ~IOP_XATTR;
1681+
1682+
if (S_ISREG(inode->i_mode))
1683+
inode->i_op = &reiserfs_priv_file_inode_operations;
1684+
else if (S_ISDIR(inode->i_mode))
1685+
inode->i_op = &reiserfs_priv_dir_inode_operations;
1686+
else if (S_ISLNK(inode->i_mode))
1687+
inode->i_op = &reiserfs_priv_symlink_inode_operations;
1688+
else
1689+
inode->i_op = &reiserfs_priv_special_inode_operations;
1690+
}
1691+
16521692
/* directories can handle most operations... */
16531693
const struct inode_operations reiserfs_dir_inode_operations = {
16541694
.create = reiserfs_create,

fs/reiserfs/reiserfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,6 +3106,7 @@ int reiserfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
31063106
int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
31073107

31083108
/* namei.c */
3109+
void reiserfs_init_priv_inode(struct inode *inode);
31093110
void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
31103111
int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
31113112
struct treepath *path, struct reiserfs_dir_entry *de);
@@ -3175,6 +3176,7 @@ void reiserfs_unmap_buffer(struct buffer_head *);
31753176

31763177
/* file.c */
31773178
extern const struct inode_operations reiserfs_file_inode_operations;
3179+
extern const struct inode_operations reiserfs_priv_file_inode_operations;
31783180
extern const struct file_operations reiserfs_file_operations;
31793181
extern const struct address_space_operations reiserfs_address_space_operations;
31803182

fs/reiserfs/xattr.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,7 @@ static int create_privroot(struct dentry *dentry)
896896
return -EOPNOTSUPP;
897897
}
898898

899-
d_inode(dentry)->i_flags |= S_PRIVATE;
900-
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
899+
reiserfs_init_priv_inode(d_inode(dentry));
901900
reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
902901
"storage.\n", PRIVROOT_NAME);
903902

@@ -979,10 +978,8 @@ int reiserfs_lookup_privroot(struct super_block *s)
979978
if (!IS_ERR(dentry)) {
980979
REISERFS_SB(s)->priv_root = dentry;
981980
d_set_d_op(dentry, &xattr_lookup_poison_ops);
982-
if (d_really_is_positive(dentry)) {
983-
d_inode(dentry)->i_flags |= S_PRIVATE;
984-
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
985-
}
981+
if (d_really_is_positive(dentry))
982+
reiserfs_init_priv_inode(d_inode(dentry));
986983
} else
987984
err = PTR_ERR(dentry);
988985
inode_unlock(d_inode(s->s_root));

0 commit comments

Comments
 (0)