Skip to content

Commit 0110c35

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more vfs updates from Al Viro: "In this pile: - autofs-namespace series - dedupe stuff - more struct path constification" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (40 commits) ocfs2: implement the VFS clone_range, copy_range, and dedupe_range features ocfs2: charge quota for reflinked blocks ocfs2: fix bad pointer cast ocfs2: always unlock when completing dio writes ocfs2: don't eat io errors during _dio_end_io_write ocfs2: budget for extent tree splits when adding refcount flag ocfs2: prohibit refcounted swapfiles ocfs2: add newlines to some error messages ocfs2: convert inode refcount test to a helper simple_write_end(): don't zero in short copy into uptodate exofs: don't mess with simple_write_{begin,end} 9p: saner ->write_end() on failing copy into non-uptodate page fix gfs2_stuffed_write_end() on short copies fix ceph_write_end() nfs_write_end(): fix handling of short copies vfs: refactor clone/dedupe_file_range common functions fs: try to clone files first in vfs_copy_file_range vfs: misc struct path constification namespace.c: constify struct path passed to a bunch of primitives quota: constify struct path in quota_on ...
2 parents d9cb5bf + 9763f7a commit 0110c35

64 files changed

Lines changed: 1027 additions & 509 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/filesystems/Locking‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ prototypes:
2020
void (*d_iput)(struct dentry *, struct inode *);
2121
char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen);
2222
struct vfsmount *(*d_automount)(struct path *path);
23-
int (*d_manage)(struct dentry *, bool);
23+
int (*d_manage)(const struct path *, bool);
2424
struct dentry *(*d_real)(struct dentry *, const struct inode *,
2525
unsigned int);
2626

‎Documentation/filesystems/vfs.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ struct dentry_operations {
948948
void (*d_iput)(struct dentry *, struct inode *);
949949
char *(*d_dname)(struct dentry *, char *, int);
950950
struct vfsmount *(*d_automount)(struct path *);
951-
int (*d_manage)(struct dentry *, bool);
951+
int (*d_manage)(const struct path *, bool);
952952
struct dentry *(*d_real)(struct dentry *, const struct inode *,
953953
unsigned int);
954954
};

‎arch/powerpc/oprofile/cell/spu_task_sync.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static int release_cached_info(int spu_index)
295295
* dcookie user still being registered (namely, the reader
296296
* of the event buffer).
297297
*/
298-
static inline unsigned long fast_get_dcookie(struct path *path)
298+
static inline unsigned long fast_get_dcookie(const struct path *path)
299299
{
300300
unsigned long cookie;
301301

‎drivers/oprofile/buffer_sync.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void sync_stop(void)
206206
* because we cannot reach this code without at least one
207207
* dcookie user still being registered (namely, the reader
208208
* of the event buffer). */
209-
static inline unsigned long fast_get_dcookie(struct path *path)
209+
static inline unsigned long fast_get_dcookie(const struct path *path)
210210
{
211211
unsigned long cookie;
212212

‎fs/9p/vfs_addr.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,10 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
310310

311311
p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
312312

313-
if (unlikely(copied < len)) {
314-
/*
315-
* zero out the rest of the area
316-
*/
317-
unsigned from = pos & (PAGE_SIZE - 1);
318-
319-
zero_user(page, from + copied, len - copied);
320-
flush_dcache_page(page);
313+
if (unlikely(copied < len && !PageUptodate(page))) {
314+
copied = 0;
315+
goto out;
321316
}
322-
323-
if (!PageUptodate(page))
324-
SetPageUptodate(page);
325317
/*
326318
* No need to use i_size_read() here, the i_size
327319
* cannot change under us because we hold the i_mutex.
@@ -331,6 +323,7 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
331323
i_size_write(inode, last_pos);
332324
}
333325
set_page_dirty(page);
326+
out:
334327
unlock_page(page);
335328
put_page(page);
336329

‎fs/autofs4/autofs_i.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void autofs4_free_ino(struct autofs_info *);
145145

146146
/* Expiration */
147147
int is_autofs4_dentry(struct dentry *);
148-
int autofs4_expire_wait(struct dentry *dentry, int rcu_walk);
148+
int autofs4_expire_wait(const struct path *path, int rcu_walk);
149149
int autofs4_expire_run(struct super_block *, struct vfsmount *,
150150
struct autofs_sb_info *,
151151
struct autofs_packet_expire __user *);
@@ -217,7 +217,8 @@ static inline int autofs_prepare_pipe(struct file *pipe)
217217

218218
/* Queue management functions */
219219

220-
int autofs4_wait(struct autofs_sb_info *, struct dentry *, enum autofs_notify);
220+
int autofs4_wait(struct autofs_sb_info *,
221+
const struct path *, enum autofs_notify);
221222
int autofs4_wait_release(struct autofs_sb_info *, autofs_wqt_t, int);
222223
void autofs4_catatonic_mode(struct autofs_sb_info *);
223224

‎fs/autofs4/dev-ioctl.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static int autofs_dev_ioctl_protosubver(struct file *fp,
204204
/* Find the topmost mount satisfying test() */
205205
static int find_autofs_mount(const char *pathname,
206206
struct path *res,
207-
int test(struct path *path, void *data),
207+
int test(const struct path *path, void *data),
208208
void *data)
209209
{
210210
struct path path;
@@ -230,12 +230,12 @@ static int find_autofs_mount(const char *pathname,
230230
return err;
231231
}
232232

233-
static int test_by_dev(struct path *path, void *p)
233+
static int test_by_dev(const struct path *path, void *p)
234234
{
235235
return path->dentry->d_sb->s_dev == *(dev_t *)p;
236236
}
237237

238-
static int test_by_type(struct path *path, void *p)
238+
static int test_by_type(const struct path *path, void *p)
239239
{
240240
struct autofs_info *ino = autofs4_dentry_ino(path->dentry);
241241

@@ -468,7 +468,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
468468
ino = autofs4_dentry_ino(path.dentry);
469469
if (ino) {
470470
err = 0;
471-
autofs4_expire_wait(path.dentry, 0);
471+
autofs4_expire_wait(&path, 0);
472472
spin_lock(&sbi->fs_lock);
473473
param->requester.uid =
474474
from_kuid_munged(current_user_ns(), ino->uid);
@@ -575,7 +575,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
575575

576576
devid = new_encode_dev(dev);
577577

578-
err = have_submounts(path.dentry);
578+
err = path_has_submounts(&path);
579579

580580
if (follow_down_one(&path))
581581
magic = path.dentry->d_sb->s_magic;

‎fs/autofs4/expire.c‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,26 +310,29 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
310310
now = jiffies;
311311
timeout = sbi->exp_timeout;
312312

313-
spin_lock(&sbi->fs_lock);
314-
ino = autofs4_dentry_ino(root);
315-
/* No point expiring a pending mount */
316-
if (ino->flags & AUTOFS_INF_PENDING)
317-
goto out;
318313
if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
314+
spin_lock(&sbi->fs_lock);
315+
ino = autofs4_dentry_ino(root);
316+
/* No point expiring a pending mount */
317+
if (ino->flags & AUTOFS_INF_PENDING) {
318+
spin_unlock(&sbi->fs_lock);
319+
goto out;
320+
}
319321
ino->flags |= AUTOFS_INF_WANT_EXPIRE;
320322
spin_unlock(&sbi->fs_lock);
321323
synchronize_rcu();
322-
spin_lock(&sbi->fs_lock);
323324
if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
325+
spin_lock(&sbi->fs_lock);
324326
ino->flags |= AUTOFS_INF_EXPIRING;
325327
init_completion(&ino->expire_complete);
326328
spin_unlock(&sbi->fs_lock);
327329
return root;
328330
}
331+
spin_lock(&sbi->fs_lock);
329332
ino->flags &= ~AUTOFS_INF_WANT_EXPIRE;
333+
spin_unlock(&sbi->fs_lock);
330334
}
331335
out:
332-
spin_unlock(&sbi->fs_lock);
333336
dput(root);
334337

335338
return NULL;
@@ -495,8 +498,9 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
495498
return expired;
496499
}
497500

498-
int autofs4_expire_wait(struct dentry *dentry, int rcu_walk)
501+
int autofs4_expire_wait(const struct path *path, int rcu_walk)
499502
{
503+
struct dentry *dentry = path->dentry;
500504
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
501505
struct autofs_info *ino = autofs4_dentry_ino(dentry);
502506
int status;
@@ -525,7 +529,7 @@ int autofs4_expire_wait(struct dentry *dentry, int rcu_walk)
525529

526530
pr_debug("waiting for expire %p name=%pd\n", dentry, dentry);
527531

528-
status = autofs4_wait(sbi, dentry, NFY_NONE);
532+
status = autofs4_wait(sbi, path, NFY_NONE);
529533
wait_for_completion(&ino->expire_complete);
530534

531535
pr_debug("expire done status=%d\n", status);
@@ -592,11 +596,12 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
592596

593597
if (dentry) {
594598
struct autofs_info *ino = autofs4_dentry_ino(dentry);
599+
const struct path path = { .mnt = mnt, .dentry = dentry };
595600

596601
/* This is synchronous because it makes the daemon a
597602
* little easier
598603
*/
599-
ret = autofs4_wait(sbi, dentry, NFY_EXPIRE);
604+
ret = autofs4_wait(sbi, &path, NFY_EXPIRE);
600605

601606
spin_lock(&sbi->fs_lock);
602607
/* avoid rapid-fire expire attempts if expiry fails */

‎fs/autofs4/root.c‎

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file);
3232
static struct dentry *autofs4_lookup(struct inode *,
3333
struct dentry *, unsigned int);
3434
static struct vfsmount *autofs4_d_automount(struct path *);
35-
static int autofs4_d_manage(struct dentry *, bool);
35+
static int autofs4_d_manage(const struct path *, bool);
3636
static void autofs4_dentry_release(struct dentry *);
3737

3838
const struct file_operations autofs4_root_operations = {
@@ -123,7 +123,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
123123
* it.
124124
*/
125125
spin_lock(&sbi->lookup_lock);
126-
if (!d_mountpoint(dentry) && simple_empty(dentry)) {
126+
if (!path_is_mountpoint(&file->f_path) && simple_empty(dentry)) {
127127
spin_unlock(&sbi->lookup_lock);
128128
return -ENOENT;
129129
}
@@ -269,39 +269,41 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry,
269269
return NULL;
270270
}
271271

272-
static int autofs4_mount_wait(struct dentry *dentry, bool rcu_walk)
272+
static int autofs4_mount_wait(const struct path *path, bool rcu_walk)
273273
{
274-
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
275-
struct autofs_info *ino = autofs4_dentry_ino(dentry);
274+
struct autofs_sb_info *sbi = autofs4_sbi(path->dentry->d_sb);
275+
struct autofs_info *ino = autofs4_dentry_ino(path->dentry);
276276
int status = 0;
277277

278278
if (ino->flags & AUTOFS_INF_PENDING) {
279279
if (rcu_walk)
280280
return -ECHILD;
281-
pr_debug("waiting for mount name=%pd\n", dentry);
282-
status = autofs4_wait(sbi, dentry, NFY_MOUNT);
281+
pr_debug("waiting for mount name=%pd\n", path->dentry);
282+
status = autofs4_wait(sbi, path, NFY_MOUNT);
283283
pr_debug("mount wait done status=%d\n", status);
284284
}
285285
ino->last_used = jiffies;
286286
return status;
287287
}
288288

289-
static int do_expire_wait(struct dentry *dentry, bool rcu_walk)
289+
static int do_expire_wait(const struct path *path, bool rcu_walk)
290290
{
291+
struct dentry *dentry = path->dentry;
291292
struct dentry *expiring;
292293

293294
expiring = autofs4_lookup_expiring(dentry, rcu_walk);
294295
if (IS_ERR(expiring))
295296
return PTR_ERR(expiring);
296297
if (!expiring)
297-
return autofs4_expire_wait(dentry, rcu_walk);
298+
return autofs4_expire_wait(path, rcu_walk);
298299
else {
300+
const struct path this = { .mnt = path->mnt, .dentry = expiring };
299301
/*
300302
* If we are racing with expire the request might not
301303
* be quite complete, but the directory has been removed
302304
* so it must have been successful, just wait for it.
303305
*/
304-
autofs4_expire_wait(expiring, 0);
306+
autofs4_expire_wait(&this, 0);
305307
autofs4_del_expiring(expiring);
306308
dput(expiring);
307309
}
@@ -354,44 +356,44 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
354356
* and the directory was removed, so just go ahead and try
355357
* the mount.
356358
*/
357-
status = do_expire_wait(dentry, 0);
359+
status = do_expire_wait(path, 0);
358360
if (status && status != -EAGAIN)
359361
return NULL;
360362

361363
/* Callback to the daemon to perform the mount or wait */
362364
spin_lock(&sbi->fs_lock);
363365
if (ino->flags & AUTOFS_INF_PENDING) {
364366
spin_unlock(&sbi->fs_lock);
365-
status = autofs4_mount_wait(dentry, 0);
367+
status = autofs4_mount_wait(path, 0);
366368
if (status)
367369
return ERR_PTR(status);
368370
goto done;
369371
}
370372

371373
/*
372374
* If the dentry is a symlink it's equivalent to a directory
373-
* having d_mountpoint() true, so there's no need to call back
374-
* to the daemon.
375+
* having path_is_mountpoint() true, so there's no need to call
376+
* back to the daemon.
375377
*/
376378
if (d_really_is_positive(dentry) && d_is_symlink(dentry)) {
377379
spin_unlock(&sbi->fs_lock);
378380
goto done;
379381
}
380382

381-
if (!d_mountpoint(dentry)) {
383+
if (!path_is_mountpoint(path)) {
382384
/*
383385
* It's possible that user space hasn't removed directories
384386
* after umounting a rootless multi-mount, although it
385-
* should. For v5 have_submounts() is sufficient to handle
386-
* this because the leaves of the directory tree under the
387-
* mount never trigger mounts themselves (they have an autofs
388-
* trigger mount mounted on them). But v4 pseudo direct mounts
389-
* do need the leaves to trigger mounts. In this case we
390-
* have no choice but to use the list_empty() check and
387+
* should. For v5 path_has_submounts() is sufficient to
388+
* handle this because the leaves of the directory tree under
389+
* the mount never trigger mounts themselves (they have an
390+
* autofs trigger mount mounted on them). But v4 pseudo direct
391+
* mounts do need the leaves to trigger mounts. In this case
392+
* we have no choice but to use the list_empty() check and
391393
* require user space behave.
392394
*/
393395
if (sbi->version > 4) {
394-
if (have_submounts(dentry)) {
396+
if (path_has_submounts(path)) {
395397
spin_unlock(&sbi->fs_lock);
396398
goto done;
397399
}
@@ -403,7 +405,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
403405
}
404406
ino->flags |= AUTOFS_INF_PENDING;
405407
spin_unlock(&sbi->fs_lock);
406-
status = autofs4_mount_wait(dentry, 0);
408+
status = autofs4_mount_wait(path, 0);
407409
spin_lock(&sbi->fs_lock);
408410
ino->flags &= ~AUTOFS_INF_PENDING;
409411
if (status) {
@@ -421,8 +423,9 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
421423
return NULL;
422424
}
423425

424-
static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk)
426+
static int autofs4_d_manage(const struct path *path, bool rcu_walk)
425427
{
428+
struct dentry *dentry = path->dentry;
426429
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
427430
struct autofs_info *ino = autofs4_dentry_ino(dentry);
428431
int status;
@@ -431,20 +434,20 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk)
431434

432435
/* The daemon never waits. */
433436
if (autofs4_oz_mode(sbi)) {
434-
if (!d_mountpoint(dentry))
437+
if (!path_is_mountpoint(path))
435438
return -EISDIR;
436439
return 0;
437440
}
438441

439442
/* Wait for pending expires */
440-
if (do_expire_wait(dentry, rcu_walk) == -ECHILD)
443+
if (do_expire_wait(path, rcu_walk) == -ECHILD)
441444
return -ECHILD;
442445

443446
/*
444447
* This dentry may be under construction so wait on mount
445448
* completion.
446449
*/
447-
status = autofs4_mount_wait(dentry, rcu_walk);
450+
status = autofs4_mount_wait(path, rcu_walk);
448451
if (status)
449452
return status;
450453

@@ -460,7 +463,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk)
460463

461464
if (ino->flags & AUTOFS_INF_WANT_EXPIRE)
462465
return 0;
463-
if (d_mountpoint(dentry))
466+
if (path_is_mountpoint(path))
464467
return 0;
465468
inode = d_inode_rcu(dentry);
466469
if (inode && S_ISLNK(inode->i_mode))
@@ -487,7 +490,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk)
487490
* we can avoid needless calls ->d_automount() and avoid
488491
* an incorrect ELOOP error return.
489492
*/
490-
if ((!d_mountpoint(dentry) && !simple_empty(dentry)) ||
493+
if ((!path_is_mountpoint(path) && !simple_empty(dentry)) ||
491494
(d_really_is_positive(dentry) && d_is_symlink(dentry)))
492495
status = -EISDIR;
493496
}

0 commit comments

Comments
 (0)