@@ -32,7 +32,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file);
3232static struct dentry * autofs4_lookup (struct inode * ,
3333 struct dentry * , unsigned int );
3434static 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 );
3636static void autofs4_dentry_release (struct dentry * );
3737
3838const 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