Skip to content

Commit f01d088

Browse files
Andrea Righiamir73il
authored andcommitted
ovl: make consistent use of OVL_FS()
Always use OVL_FS() to retrieve the corresponding struct ovl_fs from a struct super_block. Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Andrea Righi <andrea.righi@canonical.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
1 parent 3629554 commit f01d088

File tree

8 files changed

+26
-24
lines changed

8 files changed

+26
-24
lines changed

fs/overlayfs/copy_up.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
932932
static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,
933933
int flags)
934934
{
935-
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
935+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
936936

937937
if (!ofs->config.metacopy)
938938
return false;

fs/overlayfs/export.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static int ovl_connect_layer(struct dentry *dentry)
183183
*/
184184
static int ovl_check_encode_origin(struct dentry *dentry)
185185
{
186-
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
186+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
187187
bool decodable = ofs->config.nfs_export;
188188

189189
/* Lower file handle for non-upper non-decodable */
@@ -444,7 +444,7 @@ static struct dentry *ovl_lookup_real_inode(struct super_block *sb,
444444
struct dentry *real,
445445
const struct ovl_layer *layer)
446446
{
447-
struct ovl_fs *ofs = sb->s_fs_info;
447+
struct ovl_fs *ofs = OVL_FS(sb);
448448
struct dentry *index = NULL;
449449
struct dentry *this = NULL;
450450
struct inode *inode;
@@ -665,7 +665,7 @@ static struct dentry *ovl_get_dentry(struct super_block *sb,
665665
struct ovl_path *lowerpath,
666666
struct dentry *index)
667667
{
668-
struct ovl_fs *ofs = sb->s_fs_info;
668+
struct ovl_fs *ofs = OVL_FS(sb);
669669
const struct ovl_layer *layer = upper ? &ofs->layers[0] : lowerpath->layer;
670670
struct dentry *real = upper ?: (index ?: lowerpath->dentry);
671671

@@ -690,7 +690,7 @@ static struct dentry *ovl_get_dentry(struct super_block *sb,
690690
static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
691691
struct ovl_fh *fh)
692692
{
693-
struct ovl_fs *ofs = sb->s_fs_info;
693+
struct ovl_fs *ofs = OVL_FS(sb);
694694
struct dentry *dentry;
695695
struct dentry *upper;
696696

@@ -710,7 +710,7 @@ static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
710710
static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
711711
struct ovl_fh *fh)
712712
{
713-
struct ovl_fs *ofs = sb->s_fs_info;
713+
struct ovl_fs *ofs = OVL_FS(sb);
714714
struct ovl_path origin = { };
715715
struct ovl_path *stack = &origin;
716716
struct dentry *dentry = NULL;

fs/overlayfs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static const char *ovl_get_link(struct dentry *dentry,
341341

342342
bool ovl_is_private_xattr(struct super_block *sb, const char *name)
343343
{
344-
struct ovl_fs *ofs = sb->s_fs_info;
344+
struct ovl_fs *ofs = OVL_FS(sb);
345345

346346
if (ofs->config.userxattr)
347347
return strncmp(name, OVL_XATTR_USER_PREFIX,
@@ -696,7 +696,7 @@ int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
696696
int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags)
697697
{
698698
if (flags & S_ATIME) {
699-
struct ovl_fs *ofs = inode->i_sb->s_fs_info;
699+
struct ovl_fs *ofs = OVL_FS(inode->i_sb);
700700
struct path upperpath = {
701701
.mnt = ovl_upper_mnt(ofs),
702702
.dentry = ovl_upperdentry_dereference(OVL_I(inode)),
@@ -1291,7 +1291,7 @@ struct inode *ovl_get_trap_inode(struct super_block *sb, struct dentry *dir)
12911291
static bool ovl_hash_bylower(struct super_block *sb, struct dentry *upper,
12921292
struct dentry *lower, bool index)
12931293
{
1294-
struct ovl_fs *ofs = sb->s_fs_info;
1294+
struct ovl_fs *ofs = OVL_FS(sb);
12951295

12961296
/* No, if pure upper */
12971297
if (!lower)

fs/overlayfs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ static int ovl_fix_origin(struct ovl_fs *ofs, struct dentry *dentry,
892892

893893
static int ovl_maybe_validate_verity(struct dentry *dentry)
894894
{
895-
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
895+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
896896
struct inode *inode = d_inode(dentry);
897897
struct path datapath, metapath;
898898
int err;
@@ -1002,7 +1002,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
10021002
{
10031003
struct ovl_entry *oe = NULL;
10041004
const struct cred *old_cred;
1005-
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
1005+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
10061006
struct ovl_entry *poe = OVL_E(dentry->d_parent);
10071007
struct ovl_entry *roe = OVL_E(dentry->d_sb->s_root);
10081008
struct ovl_path *stack = NULL, *origin_path = NULL;

fs/overlayfs/ovl_entry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ static inline struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs)
117117
return mnt_idmap(ovl_upper_mnt(ofs));
118118
}
119119

120+
extern struct file_system_type ovl_fs_type;
121+
120122
static inline struct ovl_fs *OVL_FS(struct super_block *sb)
121123
{
122124
return (struct ovl_fs *)sb->s_fs_info;

fs/overlayfs/params.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ static void ovl_free(struct fs_context *fc)
662662
static int ovl_reconfigure(struct fs_context *fc)
663663
{
664664
struct super_block *sb = fc->root->d_sb;
665-
struct ovl_fs *ofs = sb->s_fs_info;
665+
struct ovl_fs *ofs = OVL_FS(sb);
666666
struct super_block *upper_sb;
667667
int ret = 0;
668668

@@ -947,7 +947,7 @@ int ovl_fs_params_verify(const struct ovl_fs_context *ctx,
947947
int ovl_show_options(struct seq_file *m, struct dentry *dentry)
948948
{
949949
struct super_block *sb = dentry->d_sb;
950-
struct ovl_fs *ofs = sb->s_fs_info;
950+
struct ovl_fs *ofs = OVL_FS(sb);
951951
size_t nr, nr_merged_lower = ofs->numlayer - ofs->numdatalayer;
952952
const struct ovl_layer *data_layers = &ofs->layers[nr_merged_lower];
953953

fs/overlayfs/super.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static void ovl_destroy_inode(struct inode *inode)
185185

186186
static void ovl_put_super(struct super_block *sb)
187187
{
188-
struct ovl_fs *ofs = sb->s_fs_info;
188+
struct ovl_fs *ofs = OVL_FS(sb);
189189

190190
if (ofs)
191191
ovl_free_fs(ofs);
@@ -194,7 +194,7 @@ static void ovl_put_super(struct super_block *sb)
194194
/* Sync real dirty inodes in upper filesystem (if it exists) */
195195
static int ovl_sync_fs(struct super_block *sb, int wait)
196196
{
197-
struct ovl_fs *ofs = sb->s_fs_info;
197+
struct ovl_fs *ofs = OVL_FS(sb);
198198
struct super_block *upper_sb;
199199
int ret;
200200

@@ -1501,7 +1501,7 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc)
15011501
return err;
15021502
}
15031503

1504-
static struct file_system_type ovl_fs_type = {
1504+
struct file_system_type ovl_fs_type = {
15051505
.owner = THIS_MODULE,
15061506
.name = "overlay",
15071507
.init_fs_context = ovl_init_fs_context,

fs/overlayfs/util.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@
1919

2020
int ovl_want_write(struct dentry *dentry)
2121
{
22-
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
22+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
2323
return mnt_want_write(ovl_upper_mnt(ofs));
2424
}
2525

2626
void ovl_drop_write(struct dentry *dentry)
2727
{
28-
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
28+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
2929
mnt_drop_write(ovl_upper_mnt(ofs));
3030
}
3131

3232
struct dentry *ovl_workdir(struct dentry *dentry)
3333
{
34-
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
34+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
3535
return ofs->workdir;
3636
}
3737

3838
const struct cred *ovl_override_creds(struct super_block *sb)
3939
{
40-
struct ovl_fs *ofs = sb->s_fs_info;
40+
struct ovl_fs *ofs = OVL_FS(sb);
4141

4242
return override_creds(ofs->creator_cred);
4343
}
@@ -63,23 +63,23 @@ int ovl_can_decode_fh(struct super_block *sb)
6363

6464
struct dentry *ovl_indexdir(struct super_block *sb)
6565
{
66-
struct ovl_fs *ofs = sb->s_fs_info;
66+
struct ovl_fs *ofs = OVL_FS(sb);
6767

6868
return ofs->indexdir;
6969
}
7070

7171
/* Index all files on copy up. For now only enabled for NFS export */
7272
bool ovl_index_all(struct super_block *sb)
7373
{
74-
struct ovl_fs *ofs = sb->s_fs_info;
74+
struct ovl_fs *ofs = OVL_FS(sb);
7575

7676
return ofs->config.nfs_export && ofs->config.index;
7777
}
7878

7979
/* Verify lower origin on lookup. For now only enabled for NFS export */
8080
bool ovl_verify_lower(struct super_block *sb)
8181
{
82-
struct ovl_fs *ofs = sb->s_fs_info;
82+
struct ovl_fs *ofs = OVL_FS(sb);
8383

8484
return ofs->config.nfs_export && ofs->config.index;
8585
}
@@ -204,7 +204,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
204204

205205
void ovl_path_upper(struct dentry *dentry, struct path *path)
206206
{
207-
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
207+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
208208

209209
path->mnt = ovl_upper_mnt(ofs);
210210
path->dentry = ovl_dentry_upper(dentry);

0 commit comments

Comments
 (0)