Skip to content

Commit 24e0a1e

Browse files
Ronnie SahlbergSteve French
authored andcommitted
cifs: switch to new mount api
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]>
1 parent 66e7b09 commit 24e0a1e

File tree

10 files changed

+1096
-1281
lines changed

10 files changed

+1096
-1281
lines changed

fs/cifs/cifs_dfs_ref.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt,
275275

276276
convert_delimiter(devname, '/');
277277

278+
/* TODO: change to call fs_context_for_mount(), fill in context directly, call fc_mount */
279+
280+
/* See afs_mntpt_do_automount in fs/afs/mntpt.c for an example */
281+
278282
/* strip first '\' from fullpath */
279283
mountdata = cifs_compose_mount_options(cifs_sb->mountdata,
280284
fullpath + 1, NULL, NULL);

fs/cifs/cifsencrypt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,11 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
661661
unsigned char *tiblob = NULL; /* target info blob */
662662
__le64 rsp_timestamp;
663663

664+
if (nls_cp == NULL) {
665+
cifs_dbg(VFS, "%s called with nls_cp==NULL\n", __func__);
666+
return -EINVAL;
667+
}
668+
664669
if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) {
665670
if (!ses->domainName) {
666671
if (ses->domainAuto) {

fs/cifs/cifsfs.c

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,6 @@ static int cifs_show_stats(struct seq_file *s, struct dentry *root)
682682
}
683683
#endif
684684

685-
static int cifs_remount(struct super_block *sb, int *flags, char *data)
686-
{
687-
sync_filesystem(sb);
688-
*flags |= SB_NODIRATIME;
689-
return 0;
690-
}
691-
692685
static int cifs_drop_inode(struct inode *inode)
693686
{
694687
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
@@ -710,7 +703,6 @@ static const struct super_operations cifs_super_ops = {
710703
as opens */
711704
.show_options = cifs_show_options,
712705
.umount_begin = cifs_umount_begin,
713-
.remount_fs = cifs_remount,
714706
#ifdef CONFIG_CIFS_STATS2
715707
.show_stats = cifs_show_stats,
716708
#endif
@@ -778,9 +770,9 @@ static int cifs_set_super(struct super_block *sb, void *data)
778770
return set_anon_super(sb, NULL);
779771
}
780772

781-
static struct dentry *
773+
struct dentry *
782774
cifs_smb3_do_mount(struct file_system_type *fs_type,
783-
int flags, const char *dev_name, void *data, bool is_smb3)
775+
int flags, struct smb3_fs_context *old_ctx)
784776
{
785777
int rc;
786778
struct super_block *sb;
@@ -794,21 +786,32 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
794786
* If CIFS_DEBUG && cifs_FYI
795787
*/
796788
if (cifsFYI)
797-
cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
789+
cifs_dbg(FYI, "Devname: %s flags: %d\n", old_ctx->UNC, flags);
798790
else
799-
cifs_info("Attempting to mount %s\n", dev_name);
791+
cifs_info("Attempting to mount %s\n", old_ctx->UNC);
792+
793+
ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
794+
if (!ctx)
795+
return ERR_PTR(-ENOMEM);
796+
rc = smb3_fs_context_dup(ctx, old_ctx);
797+
if (rc) {
798+
root = ERR_PTR(rc);
799+
goto out;
800+
}
800801

801-
ctx = cifs_get_volume_info((char *)data, dev_name, is_smb3);
802-
if (IS_ERR(ctx))
803-
return ERR_CAST(ctx);
802+
rc = cifs_setup_volume_info(ctx);
803+
if (rc) {
804+
root = ERR_PTR(rc);
805+
goto out;
806+
}
804807

805808
cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
806809
if (cifs_sb == NULL) {
807810
root = ERR_PTR(-ENOMEM);
808811
goto out_nls;
809812
}
810813

811-
cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
814+
cifs_sb->mountdata = kstrndup(ctx->mount_options, PAGE_SIZE, GFP_KERNEL);
812815
if (cifs_sb->mountdata == NULL) {
813816
root = ERR_PTR(-ENOMEM);
814817
goto out_free;
@@ -878,19 +881,6 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
878881
goto out;
879882
}
880883

881-
static struct dentry *
882-
smb3_do_mount(struct file_system_type *fs_type,
883-
int flags, const char *dev_name, void *data)
884-
{
885-
return cifs_smb3_do_mount(fs_type, flags, dev_name, data, true);
886-
}
887-
888-
static struct dentry *
889-
cifs_do_mount(struct file_system_type *fs_type,
890-
int flags, const char *dev_name, void *data)
891-
{
892-
return cifs_smb3_do_mount(fs_type, flags, dev_name, data, false);
893-
}
894884

895885
static ssize_t
896886
cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
@@ -1027,7 +1017,8 @@ cifs_setlease(struct file *file, long arg, struct file_lock **lease, void **priv
10271017
struct file_system_type cifs_fs_type = {
10281018
.owner = THIS_MODULE,
10291019
.name = "cifs",
1030-
.mount = cifs_do_mount,
1020+
.init_fs_context = smb3_init_fs_context,
1021+
.parameters = smb3_fs_parameters,
10311022
.kill_sb = cifs_kill_sb,
10321023
.fs_flags = FS_RENAME_DOES_D_MOVE,
10331024
};
@@ -1036,7 +1027,8 @@ MODULE_ALIAS_FS("cifs");
10361027
static struct file_system_type smb3_fs_type = {
10371028
.owner = THIS_MODULE,
10381029
.name = "smb3",
1039-
.mount = smb3_do_mount,
1030+
.init_fs_context = smb3_init_fs_context,
1031+
.parameters = smb3_fs_parameters,
10401032
.kill_sb = cifs_kill_sb,
10411033
.fs_flags = FS_RENAME_DOES_D_MOVE,
10421034
};

fs/cifs/cifsfs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
152152
extern void cifs_setsize(struct inode *inode, loff_t offset);
153153
extern int cifs_truncate_page(struct address_space *mapping, loff_t from);
154154

155+
struct smb3_fs_context;
156+
extern struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type,
157+
int flags, struct smb3_fs_context *ctx);
158+
155159
#ifdef CONFIG_CIFS_NFSD_EXPORT
156160
extern const struct export_operations cifs_export_ops;
157161
#endif /* CONFIG_CIFS_NFSD_EXPORT */

fs/cifs/cifsproto.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ extern int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
239239
struct cifs_sb_info *cifs_sb);
240240
extern int cifs_match_super(struct super_block *, void *);
241241
extern void cifs_cleanup_volume_info(struct smb3_fs_context *ctx);
242-
extern struct smb3_fs_context *cifs_get_volume_info(char *mount_data,
243-
const char *devname, bool is_smb3);
244242
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
245243
extern void cifs_umount(struct cifs_sb_info *);
246244
extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
@@ -554,8 +552,7 @@ extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
554552
unsigned char *p24);
555553

556554
extern int
557-
cifs_setup_volume_info(struct smb3_fs_context *ctx, char *mount_data,
558-
const char *devname, bool is_smb3);
555+
cifs_setup_volume_info(struct smb3_fs_context *ctx);
559556
extern void
560557
cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx);
561558

0 commit comments

Comments
 (0)