Commit 24e0a1ef authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: switch to new mount api

See Documentation/filesystems/mount_api.rst for details on new mount API
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 66e7b09c
......@@ -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);
......
......@@ -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) {
......
......@@ -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);
......@@ -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
......@@ -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;
......@@ -794,13 +786,24 @@ 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) {
......@@ -808,7 +811,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
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;
......@@ -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)
......@@ -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,
};
......@@ -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,
};
......
......@@ -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 */
......
......@@ -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);
......@@ -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);
......
This diff is collapsed.
......@@ -18,9 +18,9 @@
#include "cifs_debug.h"
#include "cifs_unicode.h"
#include "smb2glob.h"
#include "fs_context.h"
#include "dfs_cache.h"
#include "fs_context.h"
#define CACHE_HTABLE_SIZE 32
#define CACHE_MAX_ENTRIES 64
......@@ -1142,14 +1142,14 @@ int dfs_cache_get_tgt_referral(const char *path,
}
/**
* dfs_cache_add_vol - add a cifs volume during mount() that will be handled by
* dfs_cache_add_vol - add a cifs context during mount() that will be handled by
* DFS cache refresh worker.
*
* @mntdata: mount data.
* @ctx: cifs context.
* @fullpath: origin full path.
*
* Return zero if volume was set up correctly, otherwise non-zero.
* Return zero if context was set up correctly, otherwise non-zero.
*/
int dfs_cache_add_vol(char *mntdata, struct smb3_fs_context *ctx, const char *fullpath)
{
......@@ -1453,7 +1453,7 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi,
goto out;
}
rc = cifs_setup_volume_info(&ctx, mdata, devname, false);
rc = cifs_setup_volume_info(&ctx);
kfree(devname);
if (rc) {
......
This diff is collapsed.
......@@ -9,8 +9,11 @@
#ifndef _FS_CONTEXT_H
#define _FS_CONTEXT_H
#include <linux/parser.h>
#include "cifsglob.h"
#include <linux/parser.h>
#include <linux/fs_parser.h>
#define cifs_invalf(fc, fmt, ...) invalf(fc, fmt, ## __VA_ARGS__)
enum smb_version {
Smb_1 = 1,
......@@ -24,8 +27,6 @@ enum smb_version {
Smb_version_err
};
int cifs_parse_smb_version(char *value, struct smb3_fs_context *ctx, bool is_smb3);
enum {
Opt_cache_loose,
Opt_cache_strict,
......@@ -35,8 +36,6 @@ enum {
Opt_cache_err
};
int cifs_parse_cache_flavor(char *value, struct smb3_fs_context *ctx);
enum cifs_sec_param {
Opt_sec_krb5,
Opt_sec_krb5i,
......@@ -55,36 +54,36 @@ enum cifs_sec_param {
enum cifs_param {
/* Mount options that take no arguments */
Opt_user_xattr, Opt_nouser_xattr,
Opt_forceuid, Opt_noforceuid,
Opt_forcegid, Opt_noforcegid,
Opt_user_xattr,
Opt_forceuid,
Opt_forcegid,
Opt_noblocksend,
Opt_noautotune,
Opt_nolease,
Opt_hard, Opt_nohard,
Opt_soft, Opt_nosoft,
Opt_perm, Opt_noperm,
Opt_hard,
Opt_soft,
Opt_perm,
Opt_nodelete,
Opt_mapposix, Opt_nomapposix,
Opt_mapposix,
Opt_mapchars,
Opt_nomapchars,
Opt_sfu, Opt_nosfu,
Opt_sfu,
Opt_nodfs,
Opt_posixpaths, Opt_noposixpaths,
Opt_unix, Opt_nounix,
Opt_posixpaths,
Opt_unix,
Opt_nocase,
Opt_brl, Opt_nobrl,
Opt_handlecache, Opt_nohandlecache,
Opt_brl,
Opt_handlecache,
Opt_forcemandatorylock,
Opt_setuidfromacl,
Opt_setuids, Opt_nosetuids,
Opt_dynperm, Opt_nodynperm,
Opt_intr, Opt_nointr,
Opt_strictsync, Opt_nostrictsync,
Opt_serverino, Opt_noserverino,
Opt_setuids,
Opt_dynperm,
Opt_intr,
Opt_strictsync,
Opt_serverino,
Opt_rwpidforward,
Opt_cifsacl, Opt_nocifsacl,
Opt_acl, Opt_noacl,
Opt_cifsacl,
Opt_acl,
Opt_locallease,
Opt_sign,
Opt_ignore_signature,
......@@ -95,13 +94,13 @@ enum cifs_param {
Opt_multiuser,
Opt_sloppy,
Opt_nosharesock,
Opt_persistent, Opt_nopersistent,
Opt_resilient, Opt_noresilient,
Opt_persistent,
Opt_resilient,
Opt_domainauto,
Opt_rdma,
Opt_modesid,
Opt_rootfs,
Opt_multichannel, Opt_nomultichannel,
Opt_multichannel,
Opt_compress,
/* Mount options which take numeric value */
......@@ -142,11 +141,6 @@ enum cifs_param {
/* Mount options to be ignored */
Opt_ignore,
/* Options which could be blank */
Opt_blank_pass,
Opt_blank_user,
Opt_blank_ip,
Opt_err
};
......@@ -247,9 +241,23 @@ struct smb3_fs_context {
unsigned int max_channels;
__u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
bool rootfs:1; /* if it's a SMB root file system */
char *mount_options;
};
extern int cifs_parse_security_flavors(char *value, struct smb3_fs_context *ctx);
extern const struct fs_parameter_spec smb3_fs_parameters[];
extern int cifs_parse_cache_flavor(char *value,
struct smb3_fs_context *ctx);
extern int cifs_parse_security_flavors(char *value,
struct smb3_fs_context *ctx);
extern int smb3_init_fs_context(struct fs_context *fc);
static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
{
return fc->fs_private;
}
extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
#endif
......@@ -195,7 +195,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
* We need to setup at least the fields used for negprot and
* sesssetup.
*
* We only need the volume here, so we can reuse memory from
* We only need the ctx here, so we can reuse memory from
* the session and server without caring about memory
* management.
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment