Skip to content

Commit

Permalink
cifs: switch to new mount api
Browse files Browse the repository at this point in the history
See Documentation/filesystems/mount_api.rst for details on new mount API

Signed-off-by: Ronnie Sahlberg <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
Ronnie Sahlberg authored and Steve French committed Dec 14, 2020
1 parent 66e7b09 commit 24e0a1e
Show file tree
Hide file tree
Showing 10 changed files with 1,096 additions and 1,281 deletions.
4 changes: 4 additions & 0 deletions fs/cifs/cifs_dfs_ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt,

convert_delimiter(devname, '/');

/* TODO: change to call fs_context_for_mount(), fill in context directly, call fc_mount */

/* See afs_mntpt_do_automount in fs/afs/mntpt.c for an example */

/* strip first '\' from fullpath */
mountdata = cifs_compose_mount_options(cifs_sb->mountdata,
fullpath + 1, NULL, NULL);
Expand Down
5 changes: 5 additions & 0 deletions fs/cifs/cifsencrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
unsigned char *tiblob = NULL; /* target info blob */
__le64 rsp_timestamp;

if (nls_cp == NULL) {
cifs_dbg(VFS, "%s called with nls_cp==NULL\n", __func__);
return -EINVAL;
}

if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) {
if (!ses->domainName) {
if (ses->domainAuto) {
Expand Down
54 changes: 23 additions & 31 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,13 +682,6 @@ static int cifs_show_stats(struct seq_file *s, struct dentry *root)
}
#endif

static int cifs_remount(struct super_block *sb, int *flags, char *data)
{
sync_filesystem(sb);
*flags |= SB_NODIRATIME;
return 0;
}

static int cifs_drop_inode(struct inode *inode)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
Expand All @@ -710,7 +703,6 @@ static const struct super_operations cifs_super_ops = {
as opens */
.show_options = cifs_show_options,
.umount_begin = cifs_umount_begin,
.remount_fs = cifs_remount,
#ifdef CONFIG_CIFS_STATS2
.show_stats = cifs_show_stats,
#endif
Expand Down Expand Up @@ -778,9 +770,9 @@ static int cifs_set_super(struct super_block *sb, void *data)
return set_anon_super(sb, NULL);
}

static struct dentry *
struct dentry *
cifs_smb3_do_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data, bool is_smb3)
int flags, struct smb3_fs_context *old_ctx)
{
int rc;
struct super_block *sb;
Expand All @@ -794,21 +786,32 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
* If CIFS_DEBUG && cifs_FYI
*/
if (cifsFYI)
cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
cifs_dbg(FYI, "Devname: %s flags: %d\n", old_ctx->UNC, flags);
else
cifs_info("Attempting to mount %s\n", dev_name);
cifs_info("Attempting to mount %s\n", old_ctx->UNC);

ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
if (!ctx)
return ERR_PTR(-ENOMEM);
rc = smb3_fs_context_dup(ctx, old_ctx);
if (rc) {
root = ERR_PTR(rc);
goto out;
}

ctx = cifs_get_volume_info((char *)data, dev_name, is_smb3);
if (IS_ERR(ctx))
return ERR_CAST(ctx);
rc = cifs_setup_volume_info(ctx);
if (rc) {
root = ERR_PTR(rc);
goto out;
}

cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
if (cifs_sb == NULL) {
root = ERR_PTR(-ENOMEM);
goto out_nls;
}

cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
cifs_sb->mountdata = kstrndup(ctx->mount_options, PAGE_SIZE, GFP_KERNEL);
if (cifs_sb->mountdata == NULL) {
root = ERR_PTR(-ENOMEM);
goto out_free;
Expand Down Expand Up @@ -878,19 +881,6 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
goto out;
}

static struct dentry *
smb3_do_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
return cifs_smb3_do_mount(fs_type, flags, dev_name, data, true);
}

static struct dentry *
cifs_do_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
return cifs_smb3_do_mount(fs_type, flags, dev_name, data, false);
}

static ssize_t
cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
Expand Down Expand Up @@ -1027,7 +1017,8 @@ cifs_setlease(struct file *file, long arg, struct file_lock **lease, void **priv
struct file_system_type cifs_fs_type = {
.owner = THIS_MODULE,
.name = "cifs",
.mount = cifs_do_mount,
.init_fs_context = smb3_init_fs_context,
.parameters = smb3_fs_parameters,
.kill_sb = cifs_kill_sb,
.fs_flags = FS_RENAME_DOES_D_MOVE,
};
Expand All @@ -1036,7 +1027,8 @@ MODULE_ALIAS_FS("cifs");
static struct file_system_type smb3_fs_type = {
.owner = THIS_MODULE,
.name = "smb3",
.mount = smb3_do_mount,
.init_fs_context = smb3_init_fs_context,
.parameters = smb3_fs_parameters,
.kill_sb = cifs_kill_sb,
.fs_flags = FS_RENAME_DOES_D_MOVE,
};
Expand Down
4 changes: 4 additions & 0 deletions fs/cifs/cifsfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
extern void cifs_setsize(struct inode *inode, loff_t offset);
extern int cifs_truncate_page(struct address_space *mapping, loff_t from);

struct smb3_fs_context;
extern struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type,
int flags, struct smb3_fs_context *ctx);

#ifdef CONFIG_CIFS_NFSD_EXPORT
extern const struct export_operations cifs_export_ops;
#endif /* CONFIG_CIFS_NFSD_EXPORT */
Expand Down
5 changes: 1 addition & 4 deletions fs/cifs/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ extern int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
struct cifs_sb_info *cifs_sb);
extern int cifs_match_super(struct super_block *, void *);
extern void cifs_cleanup_volume_info(struct smb3_fs_context *ctx);
extern struct smb3_fs_context *cifs_get_volume_info(char *mount_data,
const char *devname, bool is_smb3);
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
extern void cifs_umount(struct cifs_sb_info *);
extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
Expand Down Expand Up @@ -554,8 +552,7 @@ extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
unsigned char *p24);

extern int
cifs_setup_volume_info(struct smb3_fs_context *ctx, char *mount_data,
const char *devname, bool is_smb3);
cifs_setup_volume_info(struct smb3_fs_context *ctx);
extern void
cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx);

Expand Down
Loading

0 comments on commit 24e0a1e

Please sign in to comment.