Skip to content

Commit

Permalink
smb: client: get rid of dfs naming in automount code
Browse files Browse the repository at this point in the history
Automount code will handle both DFS links and reparse mount points.

Also, get rid of BUG_ON() in cifs_release_automount_timer() while
we're at it.

Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Paulo Alcantara authored and Steve French committed Aug 20, 2023
1 parent 561f82a commit 0a04993
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion fs/smb/client/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ exit_cifs(void)
cifs_dbg(NOISY, "exit_smb3\n");
unregister_filesystem(&cifs_fs_type);
unregister_filesystem(&smb3_fs_type);
cifs_dfs_release_automount_timer();
cifs_release_automount_timer();
exit_cifs_idmap();
#ifdef CONFIG_CIFS_SWN_UPCALL
cifs_genl_exit();
Expand Down
6 changes: 3 additions & 3 deletions fs/smb/client/cifsfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extern int cifs_fiemap(struct inode *, struct fiemap_extent_info *, u64 start,

extern const struct inode_operations cifs_file_inode_ops;
extern const struct inode_operations cifs_symlink_inode_ops;
extern const struct inode_operations cifs_dfs_referral_inode_operations;
extern const struct inode_operations cifs_namespace_inode_operations;


/* Functions related to files and directories */
Expand Down Expand Up @@ -119,9 +119,9 @@ extern const struct dentry_operations cifs_dentry_ops;
extern const struct dentry_operations cifs_ci_dentry_ops;

#ifdef CONFIG_CIFS_DFS_UPCALL
extern struct vfsmount *cifs_dfs_d_automount(struct path *path);
extern struct vfsmount *cifs_d_automount(struct path *path);
#else
static inline struct vfsmount *cifs_dfs_d_automount(struct path *path)
static inline struct vfsmount *cifs_d_automount(struct path *path)
{
return ERR_PTR(-EREMOTE);
}
Expand Down
4 changes: 2 additions & 2 deletions fs/smb/client/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ extern void cifs_put_tcp_session(struct TCP_Server_Info *server,
extern void cifs_put_tcon(struct cifs_tcon *tcon);

#if IS_ENABLED(CONFIG_CIFS_DFS_UPCALL)
extern void cifs_dfs_release_automount_timer(void);
extern void cifs_release_automount_timer(void);
#else /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
#define cifs_dfs_release_automount_timer() do { } while (0)
#define cifs_release_automount_timer() do { } while (0)
#endif /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */

void cifs_proc_init(void);
Expand Down
4 changes: 2 additions & 2 deletions fs/smb/client/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ cifs_d_revalidate(struct dentry *direntry, unsigned int flags)

const struct dentry_operations cifs_dentry_ops = {
.d_revalidate = cifs_d_revalidate,
.d_automount = cifs_dfs_d_automount,
.d_automount = cifs_d_automount,
/* d_delete: cifs_d_delete, */ /* not needed except for debugging */
};

Expand Down Expand Up @@ -872,5 +872,5 @@ const struct dentry_operations cifs_ci_dentry_ops = {
.d_revalidate = cifs_d_revalidate,
.d_hash = cifs_ci_hash,
.d_compare = cifs_ci_compare,
.d_automount = cifs_dfs_d_automount,
.d_automount = cifs_d_automount,
};
2 changes: 1 addition & 1 deletion fs/smb/client/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void cifs_set_ops(struct inode *inode)
case S_IFDIR:
#ifdef CONFIG_CIFS_DFS_UPCALL
if (IS_AUTOMOUNT(inode)) {
inode->i_op = &cifs_dfs_referral_inode_operations;
inode->i_op = &cifs_namespace_inode_operations;
} else {
#else /* NO DFS support, treat as a directory */
{
Expand Down
42 changes: 21 additions & 21 deletions fs/smb/client/namespace.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Contains the CIFS DFS referral mounting routines used for handling
* traversal via DFS junction point
* Contains mounting routines used for handling traversal via SMB junctions.
*
* Copyright (c) 2007 Igor Mammedov
* Copyright (C) International Business Machines Corp., 2008
Expand All @@ -24,27 +23,28 @@
#include "dfs.h"
#include "fs_context.h"

static LIST_HEAD(cifs_dfs_automount_list);
static LIST_HEAD(cifs_automount_list);

static void cifs_dfs_expire_automounts(struct work_struct *work);
static DECLARE_DELAYED_WORK(cifs_dfs_automount_task,
cifs_dfs_expire_automounts);
static int cifs_dfs_mountpoint_expiry_timeout = 500 * HZ;
static void cifs_expire_automounts(struct work_struct *work);
static DECLARE_DELAYED_WORK(cifs_automount_task,
cifs_expire_automounts);
static int cifs_mountpoint_expiry_timeout = 500 * HZ;

static void cifs_dfs_expire_automounts(struct work_struct *work)
static void cifs_expire_automounts(struct work_struct *work)
{
struct list_head *list = &cifs_dfs_automount_list;
struct list_head *list = &cifs_automount_list;

mark_mounts_for_expiry(list);
if (!list_empty(list))
schedule_delayed_work(&cifs_dfs_automount_task,
cifs_dfs_mountpoint_expiry_timeout);
schedule_delayed_work(&cifs_automount_task,
cifs_mountpoint_expiry_timeout);
}

void cifs_dfs_release_automount_timer(void)
void cifs_release_automount_timer(void)
{
BUG_ON(!list_empty(&cifs_dfs_automount_list));
cancel_delayed_work_sync(&cifs_dfs_automount_task);
if (WARN_ON(!list_empty(&cifs_automount_list)))
return;
cancel_delayed_work_sync(&cifs_automount_task);
}

/**
Expand Down Expand Up @@ -132,7 +132,7 @@ static int set_dest_addr(struct smb3_fs_context *ctx)
/*
* Create a vfsmount that we can automount
*/
static struct vfsmount *cifs_dfs_do_automount(struct path *path)
static struct vfsmount *cifs_do_automount(struct path *path)
{
int rc;
struct dentry *mntpt = path->dentry;
Expand Down Expand Up @@ -214,25 +214,25 @@ static struct vfsmount *cifs_dfs_do_automount(struct path *path)
/*
* Attempt to automount the referral
*/
struct vfsmount *cifs_dfs_d_automount(struct path *path)
struct vfsmount *cifs_d_automount(struct path *path)
{
struct vfsmount *newmnt;

cifs_dbg(FYI, "%s: %pd\n", __func__, path->dentry);

newmnt = cifs_dfs_do_automount(path);
newmnt = cifs_do_automount(path);
if (IS_ERR(newmnt)) {
cifs_dbg(FYI, "leaving %s [automount failed]\n" , __func__);
return newmnt;
}

mntget(newmnt); /* prevent immediate expiration */
mnt_set_expiry(newmnt, &cifs_dfs_automount_list);
schedule_delayed_work(&cifs_dfs_automount_task,
cifs_dfs_mountpoint_expiry_timeout);
mnt_set_expiry(newmnt, &cifs_automount_list);
schedule_delayed_work(&cifs_automount_task,
cifs_mountpoint_expiry_timeout);
cifs_dbg(FYI, "leaving %s [ok]\n" , __func__);
return newmnt;
}

const struct inode_operations cifs_dfs_referral_inode_operations = {
const struct inode_operations cifs_namespace_inode_operations = {
};

0 comments on commit 0a04993

Please sign in to comment.