Skip to content

Commit d8cd93e

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fixes from Al Viro: "A couple of fixes (-stable fodder) + dead code removal after the overlayfs fix. I agree that it's better to separate from the fix part to make backporting easier, but IMO it's not worth delaying said dead code removal until the next window" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: Don't reset ->total_link_count on nested calls of vfs_path_lookup() ovl: get rid of the dead code left from broken (and disabled) optimizations ovl: fix permission checking for setattr
2 parents fb7b26e + 2788cc4 commit d8cd93e

File tree

4 files changed

+15
-31
lines changed

4 files changed

+15
-31
lines changed

fs/namei.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,6 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
19961996
nd->last_type = LAST_ROOT; /* if there are only slashes... */
19971997
nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT;
19981998
nd->depth = 0;
1999-
nd->total_link_count = 0;
20001999
if (flags & LOOKUP_ROOT) {
20012000
struct dentry *root = nd->root.dentry;
20022001
struct inode *inode = root->d_inode;

fs/overlayfs/copy_up.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ int ovl_set_attr(struct dentry *upperdentry, struct kstat *stat)
195195

196196
static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
197197
struct dentry *dentry, struct path *lowerpath,
198-
struct kstat *stat, struct iattr *attr,
199-
const char *link)
198+
struct kstat *stat, const char *link)
200199
{
201200
struct inode *wdir = workdir->d_inode;
202201
struct inode *udir = upperdir->d_inode;
@@ -240,8 +239,6 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
240239

241240
mutex_lock(&newdentry->d_inode->i_mutex);
242241
err = ovl_set_attr(newdentry, stat);
243-
if (!err && attr)
244-
err = notify_change(newdentry, attr, NULL);
245242
mutex_unlock(&newdentry->d_inode->i_mutex);
246243
if (err)
247244
goto out_cleanup;
@@ -286,8 +283,7 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
286283
* that point the file will have already been copied up anyway.
287284
*/
288285
int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
289-
struct path *lowerpath, struct kstat *stat,
290-
struct iattr *attr)
286+
struct path *lowerpath, struct kstat *stat)
291287
{
292288
struct dentry *workdir = ovl_workdir(dentry);
293289
int err;
@@ -345,26 +341,19 @@ int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
345341
}
346342
upperdentry = ovl_dentry_upper(dentry);
347343
if (upperdentry) {
348-
unlock_rename(workdir, upperdir);
344+
/* Raced with another copy-up? Nothing to do, then... */
349345
err = 0;
350-
/* Raced with another copy-up? Do the setattr here */
351-
if (attr) {
352-
mutex_lock(&upperdentry->d_inode->i_mutex);
353-
err = notify_change(upperdentry, attr, NULL);
354-
mutex_unlock(&upperdentry->d_inode->i_mutex);
355-
}
356-
goto out_put_cred;
346+
goto out_unlock;
357347
}
358348

359349
err = ovl_copy_up_locked(workdir, upperdir, dentry, lowerpath,
360-
stat, attr, link);
350+
stat, link);
361351
if (!err) {
362352
/* Restore timestamps on parent (best effort) */
363353
ovl_set_timestamps(upperdir, &pstat);
364354
}
365355
out_unlock:
366356
unlock_rename(workdir, upperdir);
367-
out_put_cred:
368357
revert_creds(old_cred);
369358
put_cred(override_cred);
370359

@@ -406,7 +395,7 @@ int ovl_copy_up(struct dentry *dentry)
406395
ovl_path_lower(next, &lowerpath);
407396
err = vfs_getattr(&lowerpath, &stat);
408397
if (!err)
409-
err = ovl_copy_up_one(parent, next, &lowerpath, &stat, NULL);
398+
err = ovl_copy_up_one(parent, next, &lowerpath, &stat);
410399

411400
dput(parent);
412401
dput(next);

fs/overlayfs/inode.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include <linux/xattr.h>
1313
#include "overlayfs.h"
1414

15-
static int ovl_copy_up_last(struct dentry *dentry, struct iattr *attr,
16-
bool no_data)
15+
static int ovl_copy_up_truncate(struct dentry *dentry)
1716
{
1817
int err;
1918
struct dentry *parent;
@@ -30,10 +29,8 @@ static int ovl_copy_up_last(struct dentry *dentry, struct iattr *attr,
3029
if (err)
3130
goto out_dput_parent;
3231

33-
if (no_data)
34-
stat.size = 0;
35-
36-
err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat, attr);
32+
stat.size = 0;
33+
err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat);
3734

3835
out_dput_parent:
3936
dput(parent);
@@ -49,13 +46,13 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
4946
if (err)
5047
goto out;
5148

52-
upperdentry = ovl_dentry_upper(dentry);
53-
if (upperdentry) {
49+
err = ovl_copy_up(dentry);
50+
if (!err) {
51+
upperdentry = ovl_dentry_upper(dentry);
52+
5453
mutex_lock(&upperdentry->d_inode->i_mutex);
5554
err = notify_change(upperdentry, attr, NULL);
5655
mutex_unlock(&upperdentry->d_inode->i_mutex);
57-
} else {
58-
err = ovl_copy_up_last(dentry, attr, false);
5956
}
6057
ovl_drop_write(dentry);
6158
out:
@@ -353,7 +350,7 @@ struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags)
353350
return ERR_PTR(err);
354351

355352
if (file_flags & O_TRUNC)
356-
err = ovl_copy_up_last(dentry, NULL, true);
353+
err = ovl_copy_up_truncate(dentry);
357354
else
358355
err = ovl_copy_up(dentry);
359356
ovl_drop_write(dentry);

fs/overlayfs/overlayfs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ void ovl_cleanup(struct inode *dir, struct dentry *dentry);
194194
/* copy_up.c */
195195
int ovl_copy_up(struct dentry *dentry);
196196
int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
197-
struct path *lowerpath, struct kstat *stat,
198-
struct iattr *attr);
197+
struct path *lowerpath, struct kstat *stat);
199198
int ovl_copy_xattr(struct dentry *old, struct dentry *new);
200199
int ovl_set_attr(struct dentry *upper, struct kstat *stat);

0 commit comments

Comments
 (0)