Skip to content

Commit 08f4c7c

Browse files
author
Miklos Szeredi
committed
ovl: add accessor for ofs->upper_mnt
Next patch will remove ofs->upper_mnt, so add an accessor function for this field. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 520da69 commit 08f4c7c

File tree

7 files changed

+35
-30
lines changed

7 files changed

+35
-30
lines changed

fs/overlayfs/export.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static int ovl_check_encode_origin(struct dentry *dentry)
204204
* ovl_connect_layer() will try to make origin's layer "connected" by
205205
* copying up a "connectable" ancestor.
206206
*/
207-
if (d_is_dir(dentry) && ofs->upper_mnt)
207+
if (d_is_dir(dentry) && ovl_upper_mnt(ofs))
208208
return ovl_connect_layer(dentry);
209209

210210
/* Lower file handle for indexed and non-upper dir/non-dir */
@@ -677,10 +677,10 @@ static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
677677
struct dentry *dentry;
678678
struct dentry *upper;
679679

680-
if (!ofs->upper_mnt)
680+
if (!ovl_upper_mnt(ofs))
681681
return ERR_PTR(-EACCES);
682682

683-
upper = ovl_decode_real_fh(fh, ofs->upper_mnt, true);
683+
upper = ovl_decode_real_fh(fh, ovl_upper_mnt(ofs), true);
684684
if (IS_ERR_OR_NULL(upper))
685685
return upper;
686686

fs/overlayfs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags)
456456
if (flags & S_ATIME) {
457457
struct ovl_fs *ofs = inode->i_sb->s_fs_info;
458458
struct path upperpath = {
459-
.mnt = ofs->upper_mnt,
459+
.mnt = ovl_upper_mnt(ofs),
460460
.dentry = ovl_upperdentry_dereference(OVL_I(inode)),
461461
};
462462

@@ -921,7 +921,7 @@ static bool ovl_hash_bylower(struct super_block *sb, struct dentry *upper,
921921
return true;
922922

923923
/* Yes, if won't be copied up */
924-
if (!ofs->upper_mnt)
924+
if (!ovl_upper_mnt(ofs))
925925
return true;
926926

927927
/* No, if lower hardlink is or will be broken on copy up */

fs/overlayfs/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
489489
if (IS_ERR_OR_NULL(fh))
490490
return ERR_CAST(fh);
491491

492-
upper = ovl_decode_real_fh(fh, ofs->upper_mnt, true);
492+
upper = ovl_decode_real_fh(fh, ovl_upper_mnt(ofs), true);
493493
kfree(fh);
494494

495495
if (IS_ERR_OR_NULL(upper))

fs/overlayfs/ovl_entry.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ struct ovl_fs {
8282
struct dentry *whiteout;
8383
};
8484

85+
static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
86+
{
87+
return ofs->upper_mnt;
88+
}
89+
8590
static inline struct ovl_fs *OVL_FS(struct super_block *sb)
8691
{
8792
return (struct ovl_fs *)sb->s_fs_info;

fs/overlayfs/readdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ int ovl_indexdir_cleanup(struct ovl_fs *ofs)
11201120
struct dentry *indexdir = ofs->indexdir;
11211121
struct dentry *index = NULL;
11221122
struct inode *dir = indexdir->d_inode;
1123-
struct path path = { .mnt = ofs->upper_mnt, .dentry = indexdir };
1123+
struct path path = { .mnt = ovl_upper_mnt(ofs), .dentry = indexdir };
11241124
LIST_HEAD(list);
11251125
struct rb_root root = RB_ROOT;
11261126
struct ovl_cache_entry *p;

fs/overlayfs/super.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void ovl_free_fs(struct ovl_fs *ofs)
224224
ovl_inuse_unlock(ofs->workbasedir);
225225
dput(ofs->workbasedir);
226226
if (ofs->upperdir_locked)
227-
ovl_inuse_unlock(ofs->upper_mnt->mnt_root);
227+
ovl_inuse_unlock(ovl_upper_mnt(ofs)->mnt_root);
228228
mntput(ofs->upper_mnt);
229229
for (i = 1; i < ofs->numlayer; i++) {
230230
iput(ofs->layers[i].trap);
@@ -258,7 +258,7 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
258258
struct super_block *upper_sb;
259259
int ret;
260260

261-
if (!ofs->upper_mnt)
261+
if (!ovl_upper_mnt(ofs))
262262
return 0;
263263

264264
/*
@@ -272,7 +272,7 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
272272
if (!wait)
273273
return 0;
274274

275-
upper_sb = ofs->upper_mnt->mnt_sb;
275+
upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
276276

277277
down_read(&upper_sb->s_umount);
278278
ret = sync_filesystem(upper_sb);
@@ -310,7 +310,7 @@ static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf)
310310
/* Will this overlay be forced to mount/remount ro? */
311311
static bool ovl_force_readonly(struct ovl_fs *ofs)
312312
{
313-
return (!ofs->upper_mnt || !ofs->workdir);
313+
return (!ovl_upper_mnt(ofs) || !ofs->workdir);
314314
}
315315

316316
static const char *ovl_redirect_mode_def(void)
@@ -372,7 +372,7 @@ static int ovl_remount(struct super_block *sb, int *flags, char *data)
372372
return -EROFS;
373373

374374
if (*flags & SB_RDONLY && !sb_rdonly(sb)) {
375-
upper_sb = ofs->upper_mnt->mnt_sb;
375+
upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
376376
down_read(&upper_sb->s_umount);
377377
ret = sync_filesystem(upper_sb);
378378
up_read(&upper_sb->s_umount);
@@ -669,7 +669,7 @@ static struct dentry *ovl_workdir_create(struct ovl_fs *ofs,
669669
const char *name, bool persist)
670670
{
671671
struct inode *dir = ofs->workbasedir->d_inode;
672-
struct vfsmount *mnt = ofs->upper_mnt;
672+
struct vfsmount *mnt = ovl_upper_mnt(ofs);
673673
struct dentry *work;
674674
int err;
675675
bool retried = false;
@@ -1122,7 +1122,7 @@ static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs,
11221122
if (upper_mnt->mnt_sb->s_flags & SB_NOSEC)
11231123
sb->s_flags |= SB_NOSEC;
11241124

1125-
if (ovl_inuse_trylock(ofs->upper_mnt->mnt_root)) {
1125+
if (ovl_inuse_trylock(ovl_upper_mnt(ofs)->mnt_root)) {
11261126
ofs->upperdir_locked = true;
11271127
} else {
11281128
err = ovl_report_in_use(ofs, "upperdir");
@@ -1198,7 +1198,7 @@ static int ovl_check_rename_whiteout(struct dentry *workdir)
11981198
static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
11991199
struct path *workpath)
12001200
{
1201-
struct vfsmount *mnt = ofs->upper_mnt;
1201+
struct vfsmount *mnt = ovl_upper_mnt(ofs);
12021202
struct dentry *temp;
12031203
bool rename_whiteout;
12041204
bool d_type;
@@ -1342,7 +1342,7 @@ static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ofs,
13421342
static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
13431343
struct ovl_entry *oe, struct path *upperpath)
13441344
{
1345-
struct vfsmount *mnt = ofs->upper_mnt;
1345+
struct vfsmount *mnt = ovl_upper_mnt(ofs);
13461346
int err;
13471347

13481348
err = mnt_want_write(mnt);
@@ -1398,7 +1398,7 @@ static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
13981398
{
13991399
unsigned int i;
14001400

1401-
if (!ofs->config.nfs_export && !ofs->upper_mnt)
1401+
if (!ofs->config.nfs_export && !ovl_upper_mnt(ofs))
14021402
return true;
14031403

14041404
for (i = 0; i < ofs->numfs; i++) {
@@ -1477,7 +1477,7 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
14771477
/* idx/fsid 0 are reserved for upper fs even with lower only overlay */
14781478
ofs->numfs++;
14791479

1480-
layers[0].mnt = ofs->upper_mnt;
1480+
layers[0].mnt = ovl_upper_mnt(ofs);
14811481
layers[0].idx = 0;
14821482
layers[0].fsid = 0;
14831483
ofs->numlayer = 1;
@@ -1494,8 +1494,8 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
14941494
goto out;
14951495
}
14961496

1497-
if (ofs->upper_mnt) {
1498-
ofs->fs[0].sb = ofs->upper_mnt->mnt_sb;
1497+
if (ovl_upper_mnt(ofs)) {
1498+
ofs->fs[0].sb = ovl_upper_mnt(ofs)->mnt_sb;
14991499
ofs->fs[0].is_lower = false;
15001500
}
15011501

@@ -1550,7 +1550,7 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
15501550
* inode number or a non persistent inode number allocated from a
15511551
* dedicated range.
15521552
*/
1553-
if (ofs->numfs - !ofs->upper_mnt == 1) {
1553+
if (ofs->numfs - !ovl_upper_mnt(ofs) == 1) {
15541554
if (ofs->config.xino == OVL_XINO_ON)
15551555
pr_info("\"xino=on\" is useless with all layers on same fs, ignore.\n");
15561556
ofs->xino_mode = 0;
@@ -1699,8 +1699,8 @@ static int ovl_check_overlapping_layers(struct super_block *sb,
16991699
{
17001700
int i, err;
17011701

1702-
if (ofs->upper_mnt) {
1703-
err = ovl_check_layer(sb, ofs, ofs->upper_mnt->mnt_root,
1702+
if (ovl_upper_mnt(ofs)) {
1703+
err = ovl_check_layer(sb, ofs, ovl_upper_mnt(ofs)->mnt_root,
17041704
"upperdir");
17051705
if (err)
17061706
return err;
@@ -1836,8 +1836,8 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
18361836
if (!ofs->workdir)
18371837
sb->s_flags |= SB_RDONLY;
18381838

1839-
sb->s_stack_depth = ofs->upper_mnt->mnt_sb->s_stack_depth;
1840-
sb->s_time_gran = ofs->upper_mnt->mnt_sb->s_time_gran;
1839+
sb->s_stack_depth = ovl_upper_mnt(ofs)->mnt_sb->s_stack_depth;
1840+
sb->s_time_gran = ovl_upper_mnt(ofs)->mnt_sb->s_time_gran;
18411841

18421842
}
18431843
oe = ovl_get_lowerstack(sb, ofs);
@@ -1846,7 +1846,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
18461846
goto out_err;
18471847

18481848
/* If the upper fs is nonexistent, we mark overlayfs r/o too */
1849-
if (!ofs->upper_mnt)
1849+
if (!ovl_upper_mnt(ofs))
18501850
sb->s_flags |= SB_RDONLY;
18511851

18521852
if (!(ovl_force_readonly(ofs)) && ofs->config.index) {
@@ -1874,7 +1874,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
18741874
/* Show index=off in /proc/mounts for forced r/o mount */
18751875
if (!ofs->indexdir) {
18761876
ofs->config.index = false;
1877-
if (ofs->upper_mnt && ofs->config.nfs_export) {
1877+
if (ovl_upper_mnt(ofs) && ofs->config.nfs_export) {
18781878
pr_warn("NFS export requires an index dir, falling back to nfs_export=off.\n");
18791879
ofs->config.nfs_export = false;
18801880
}

fs/overlayfs/util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
int ovl_want_write(struct dentry *dentry)
1919
{
2020
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
21-
return mnt_want_write(ofs->upper_mnt);
21+
return mnt_want_write(ovl_upper_mnt(ofs));
2222
}
2323

2424
void ovl_drop_write(struct dentry *dentry)
2525
{
2626
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
27-
mnt_drop_write(ofs->upper_mnt);
27+
mnt_drop_write(ovl_upper_mnt(ofs));
2828
}
2929

3030
struct dentry *ovl_workdir(struct dentry *dentry)
@@ -150,7 +150,7 @@ void ovl_path_upper(struct dentry *dentry, struct path *path)
150150
{
151151
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
152152

153-
path->mnt = ofs->upper_mnt;
153+
path->mnt = ovl_upper_mnt(ofs);
154154
path->dentry = ovl_dentry_upper(dentry);
155155
}
156156

0 commit comments

Comments
 (0)