Skip to content

Commit 1346416

Browse files
author
Miklos Szeredi
committed
ovl: layer is const
The ovl_layer struct is never modified except at initialization. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent b7bf990 commit 1346416

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

fs/overlayfs/export.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static struct dentry *ovl_dentry_real_at(struct dentry *dentry, int idx)
358358
*/
359359
static struct dentry *ovl_lookup_real_one(struct dentry *connected,
360360
struct dentry *real,
361-
struct ovl_layer *layer)
361+
const struct ovl_layer *layer)
362362
{
363363
struct inode *dir = d_inode(connected);
364364
struct dentry *this, *parent = NULL;
@@ -414,14 +414,14 @@ static struct dentry *ovl_lookup_real_one(struct dentry *connected,
414414

415415
static struct dentry *ovl_lookup_real(struct super_block *sb,
416416
struct dentry *real,
417-
struct ovl_layer *layer);
417+
const struct ovl_layer *layer);
418418

419419
/*
420420
* Lookup an indexed or hashed overlay dentry by real inode.
421421
*/
422422
static struct dentry *ovl_lookup_real_inode(struct super_block *sb,
423423
struct dentry *real,
424-
struct ovl_layer *layer)
424+
const struct ovl_layer *layer)
425425
{
426426
struct ovl_fs *ofs = sb->s_fs_info;
427427
struct dentry *index = NULL;
@@ -486,7 +486,7 @@ static struct dentry *ovl_lookup_real_inode(struct super_block *sb,
486486
*/
487487
static struct dentry *ovl_lookup_real_ancestor(struct super_block *sb,
488488
struct dentry *real,
489-
struct ovl_layer *layer)
489+
const struct ovl_layer *layer)
490490
{
491491
struct dentry *next, *parent = NULL;
492492
struct dentry *ancestor = ERR_PTR(-EIO);
@@ -539,7 +539,7 @@ static struct dentry *ovl_lookup_real_ancestor(struct super_block *sb,
539539
*/
540540
static struct dentry *ovl_lookup_real(struct super_block *sb,
541541
struct dentry *real,
542-
struct ovl_layer *layer)
542+
const struct ovl_layer *layer)
543543
{
544544
struct dentry *connected;
545545
int err = 0;
@@ -645,7 +645,7 @@ static struct dentry *ovl_get_dentry(struct super_block *sb,
645645
struct dentry *index)
646646
{
647647
struct ovl_fs *ofs = sb->s_fs_info;
648-
struct ovl_layer *layer = upper ? &ofs->layers[0] : lowerpath->layer;
648+
const struct ovl_layer *layer = upper ? &ofs->layers[0] : lowerpath->layer;
649649
struct dentry *real = upper ?: (index ?: lowerpath->dentry);
650650

651651
/*

fs/overlayfs/overlayfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path);
239239
struct dentry *ovl_dentry_upper(struct dentry *dentry);
240240
struct dentry *ovl_dentry_lower(struct dentry *dentry);
241241
struct dentry *ovl_dentry_lowerdata(struct dentry *dentry);
242-
struct ovl_layer *ovl_layer_lower(struct dentry *dentry);
242+
const struct ovl_layer *ovl_layer_lower(struct dentry *dentry);
243243
struct dentry *ovl_dentry_real(struct dentry *dentry);
244244
struct dentry *ovl_i_dentry_upper(struct inode *inode);
245245
struct inode *ovl_inode_upper(struct inode *inode);

fs/overlayfs/ovl_entry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct ovl_layer {
4040
};
4141

4242
struct ovl_path {
43-
struct ovl_layer *layer;
43+
const struct ovl_layer *layer;
4444
struct dentry *dentry;
4545
};
4646

@@ -50,7 +50,7 @@ struct ovl_fs {
5050
unsigned int numlayer;
5151
/* Number of unique fs among layers including upper fs */
5252
unsigned int numfs;
53-
struct ovl_layer *layers;
53+
const struct ovl_layer *layers;
5454
struct ovl_sb *fs;
5555
/* workbasedir is the path at workdir= mount option */
5656
struct dentry *workbasedir;

fs/overlayfs/readdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static int ovl_iterate_real(struct file *file, struct dir_context *ctx)
691691
int err;
692692
struct ovl_dir_file *od = file->private_data;
693693
struct dentry *dir = file->f_path.dentry;
694-
struct ovl_layer *lower_layer = ovl_layer_lower(dir);
694+
const struct ovl_layer *lower_layer = ovl_layer_lower(dir);
695695
struct ovl_readdir_translate rdt = {
696696
.ctx.actor = ovl_fill_real,
697697
.orig_ctx = ctx,

fs/overlayfs/super.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,12 +1320,13 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
13201320
{
13211321
int err;
13221322
unsigned int i;
1323+
struct ovl_layer *layers;
13231324

13241325
err = -ENOMEM;
1325-
ofs->layers = kcalloc(numlower + 1, sizeof(struct ovl_layer),
1326-
GFP_KERNEL);
1327-
if (ofs->layers == NULL)
1326+
layers = kcalloc(numlower + 1, sizeof(struct ovl_layer), GFP_KERNEL);
1327+
if (!layers)
13281328
goto out;
1329+
ofs->layers = layers;
13291330

13301331
ofs->fs = kcalloc(numlower + 1, sizeof(struct ovl_sb), GFP_KERNEL);
13311332
if (ofs->fs == NULL)
@@ -1334,9 +1335,9 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
13341335
/* idx/fsid 0 are reserved for upper fs even with lower only overlay */
13351336
ofs->numfs++;
13361337

1337-
ofs->layers[0].mnt = ofs->upper_mnt;
1338-
ofs->layers[0].idx = 0;
1339-
ofs->layers[0].fsid = 0;
1338+
layers[0].mnt = ofs->upper_mnt;
1339+
layers[0].idx = 0;
1340+
layers[0].fsid = 0;
13401341
ofs->numlayer = 1;
13411342

13421343
/*
@@ -1389,11 +1390,11 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
13891390
*/
13901391
mnt->mnt_flags |= MNT_READONLY | MNT_NOATIME;
13911392

1392-
ofs->layers[ofs->numlayer].trap = trap;
1393-
ofs->layers[ofs->numlayer].mnt = mnt;
1394-
ofs->layers[ofs->numlayer].idx = ofs->numlayer;
1395-
ofs->layers[ofs->numlayer].fsid = fsid;
1396-
ofs->layers[ofs->numlayer].fs = &ofs->fs[fsid];
1393+
layers[ofs->numlayer].trap = trap;
1394+
layers[ofs->numlayer].mnt = mnt;
1395+
layers[ofs->numlayer].idx = ofs->numlayer;
1396+
layers[ofs->numlayer].fsid = fsid;
1397+
layers[ofs->numlayer].fs = &ofs->fs[fsid];
13971398
ofs->numlayer++;
13981399
ofs->fs[fsid].is_lower = true;
13991400
}

fs/overlayfs/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct dentry *ovl_dentry_lower(struct dentry *dentry)
186186
return oe->numlower ? oe->lowerstack[0].dentry : NULL;
187187
}
188188

189-
struct ovl_layer *ovl_layer_lower(struct dentry *dentry)
189+
const struct ovl_layer *ovl_layer_lower(struct dentry *dentry)
190190
{
191191
struct ovl_entry *oe = dentry->d_fsdata;
192192

0 commit comments

Comments
 (0)