Skip to content

Commit 72e4848

Browse files
rhvgoyalMiklos Szeredi
authored andcommitted
ovl: move some common code in a function
ovl_create_upper() and ovl_create_over_whiteout() seem to be sharing some common code which can be moved into a separate function. No functionality change. Signed-off-by: Vivek Goyal <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 58ed4e7 commit 72e4848

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

fs/overlayfs/dir.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ static int ovl_dir_getattr(struct vfsmount *mnt, struct dentry *dentry,
158158
return 0;
159159
}
160160

161+
/* Common operations required to be done after creation of file on upper */
162+
static void ovl_instantiate(struct dentry *dentry, struct inode *inode,
163+
struct dentry *newdentry)
164+
{
165+
ovl_dentry_version_inc(dentry->d_parent);
166+
ovl_dentry_update(dentry, newdentry);
167+
ovl_copyattr(newdentry->d_inode, inode);
168+
d_instantiate(dentry, inode);
169+
}
170+
161171
static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
162172
struct kstat *stat, const char *link,
163173
struct dentry *hardlink)
@@ -177,10 +187,7 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
177187
if (err)
178188
goto out_dput;
179189

180-
ovl_dentry_version_inc(dentry->d_parent);
181-
ovl_dentry_update(dentry, newdentry);
182-
ovl_copyattr(newdentry->d_inode, inode);
183-
d_instantiate(dentry, inode);
190+
ovl_instantiate(dentry, inode, newdentry);
184191
newdentry = NULL;
185192
out_dput:
186193
dput(newdentry);
@@ -363,10 +370,7 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
363370
if (err)
364371
goto out_cleanup;
365372
}
366-
ovl_dentry_version_inc(dentry->d_parent);
367-
ovl_dentry_update(dentry, newdentry);
368-
ovl_copyattr(newdentry->d_inode, inode);
369-
d_instantiate(dentry, inode);
373+
ovl_instantiate(dentry, inode, newdentry);
370374
newdentry = NULL;
371375
out_dput2:
372376
dput(upper);

0 commit comments

Comments
 (0)