Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)  *   fs/cifs/cifsfs.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *   Copyright (C) International Business Machines  Corp., 2002,2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *   Author(s): Steve French (sfrench@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *   Common Internet FileSystem (CIFS) client
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *   This library is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  *   it under the terms of the GNU Lesser General Public License as published
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  *   by the Free Software Foundation; either version 2.1 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  *   (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  *   This library is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  *   the GNU Lesser General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)  *   You should have received a copy of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20)  *   along with this library; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21)  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) /* Note that BB means BUGBUG (ie something to fix eventually) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include <linux/mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) #include <linux/vfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #include <linux/mempool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #include <linux/freezer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #include <linux/namei.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #include <linux/random.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #include <linux/uuid.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) #include <net/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) #include "cifsfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #include "cifspdu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #define DECLARE_GLOBALS_HERE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) #include "cifsglob.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) #include "cifsproto.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) #include "cifs_debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #include "cifs_fs_sb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) #include <linux/key-type.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) #include "cifs_spnego.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #include "fscache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) #include "smb2pdu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) #include "dfs_cache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60)  * DOS dates from 1980/1/1 through 2107/12/31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61)  * Protocol specifications indicate the range should be to 119, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62)  * limits maximum year to 2099. But this range has not been checked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) #define SMB_DATE_MAX (127<<9 | 12<<5 | 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) #define SMB_DATE_MIN (0<<9 | 1<<5 | 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) #define SMB_TIME_MAX (23<<11 | 59<<5 | 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) int cifsFYI = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) bool traceSMB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) bool enable_oplocks = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) bool linuxExtEnabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) bool lookupCacheEnabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) bool disable_legacy_dialects; /* false by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) bool enable_gcm_256;  /* false by default, change when more servers support it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) bool require_gcm_256; /* false by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) unsigned int global_secflags = CIFSSEC_DEF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) /* unsigned int ntlmv2_support = 0; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) unsigned int sign_CIFS_PDUs = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) static const struct super_operations cifs_super_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) module_param(CIFSMaxBufSize, uint, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) MODULE_PARM_DESC(CIFSMaxBufSize, "Network buffer size (not including header) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 				 "for CIFS requests. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 				 "Default: 16384 Range: 8192 to 130048");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) module_param(cifs_min_rcv, uint, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) MODULE_PARM_DESC(cifs_min_rcv, "Network buffers in pool. Default: 4 Range: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 				"1 to 64");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) unsigned int cifs_min_small = 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) module_param(cifs_min_small, uint, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) MODULE_PARM_DESC(cifs_min_small, "Small network buffers in pool. Default: 30 "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 				 "Range: 2 to 256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) unsigned int cifs_max_pending = CIFS_MAX_REQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) module_param(cifs_max_pending, uint, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server for "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 				   "CIFS/SMB1 dialect (N/A for SMB3) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 				   "Default: 32767 Range: 2 to 32767.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) unsigned int slow_rsp_threshold = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) module_param(slow_rsp_threshold, uint, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) MODULE_PARM_DESC(slow_rsp_threshold, "Amount of time (in seconds) to wait "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 				   "before logging that a response is delayed. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 				   "Default: 1 (if set to 0 disables msg).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) #endif /* STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) module_param(enable_oplocks, bool, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) MODULE_PARM_DESC(enable_oplocks, "Enable or disable oplocks. Default: y/Y/1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) module_param(enable_gcm_256, bool, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) MODULE_PARM_DESC(enable_gcm_256, "Enable requesting strongest (256 bit) GCM encryption. Default: n/N/0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) module_param(require_gcm_256, bool, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) MODULE_PARM_DESC(require_gcm_256, "Require strongest (256 bit) GCM encryption. Default: n/N/0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) module_param(disable_legacy_dialects, bool, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) MODULE_PARM_DESC(disable_legacy_dialects, "To improve security it may be "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 				  "helpful to restrict the ability to "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 				  "override the default dialects (SMB2.1, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 				  "SMB3 and SMB3.02) on mount with old "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 				  "dialects (CIFS/SMB1 and SMB2) since "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 				  "vers=1.0 (CIFS/SMB1) and vers=2.0 are weaker"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 				  " and less secure. Default: n/N/0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) extern mempool_t *cifs_sm_req_poolp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) extern mempool_t *cifs_req_poolp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) extern mempool_t *cifs_mid_poolp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) struct workqueue_struct	*cifsiod_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) struct workqueue_struct	*decrypt_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) struct workqueue_struct	*fileinfo_put_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) struct workqueue_struct	*cifsoplockd_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) __u32 cifs_lock_secret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135)  * Bumps refcount for cifs super block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136)  * Note that it should be only called if a referece to VFS super block is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137)  * already held, e.g. in open-type syscalls context. Otherwise it can race with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138)  * atomic_dec_and_test in deactivate_locked_super.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) cifs_sb_active(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	struct cifs_sb_info *server = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	if (atomic_inc_return(&server->active) == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 		atomic_inc(&sb->s_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) cifs_sb_deactive(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	struct cifs_sb_info *server = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	if (atomic_dec_and_test(&server->active))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 		deactivate_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) cifs_read_super(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	struct cifs_sb_info *cifs_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	struct timespec64 ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	cifs_sb = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	tcon = cifs_sb_master_tcon(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 		sb->s_flags |= SB_POSIXACL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	if (tcon->snapshot_time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 		sb->s_flags |= SB_RDONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 		sb->s_maxbytes = MAX_LFS_FILESIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 		sb->s_maxbytes = MAX_NON_LFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	 * Some very old servers like DOS and OS/2 used 2 second granularity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 	 * (while all current servers use 100ns granularity - see MS-DTYP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	 * but 1 second is the maximum allowed granularity for the VFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	 * so for old servers set time granularity to 1 second while for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	 * everything else (current servers) set it to 100ns.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	if ((tcon->ses->server->vals->protocol_id == SMB10_PROT_ID) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	    ((tcon->ses->capabilities &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	      tcon->ses->server->vals->cap_nt_find) == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	    !tcon->unix_ext) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 		sb->s_time_gran = 1000000000; /* 1 second is max allowed gran */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 		ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MIN), 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 		sb->s_time_min = ts.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 		ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MAX),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 				    cpu_to_le16(SMB_TIME_MAX), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 		sb->s_time_max = ts.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 		 * Almost every server, including all SMB2+, uses DCE TIME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 		 * ie 100 nanosecond units, since 1601.  See MS-DTYP and MS-FSCC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 		sb->s_time_gran = 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 		ts = cifs_NTtimeToUnix(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 		sb->s_time_min = ts.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 		ts = cifs_NTtimeToUnix(cpu_to_le64(S64_MAX));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 		sb->s_time_max = ts.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	sb->s_magic = CIFS_MAGIC_NUMBER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	sb->s_op = &cifs_super_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	sb->s_xattr = cifs_xattr_handlers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	rc = super_setup_bdi(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 		goto out_no_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	/* tune readahead according to rsize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	sb->s_bdi->ra_pages = cifs_sb->rsize / PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	sb->s_blocksize = CIFS_MAX_MSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	sb->s_blocksize_bits = 14;	/* default 2**14 = CIFS_MAX_MSGSIZE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	inode = cifs_root_iget(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	if (IS_ERR(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 		rc = PTR_ERR(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 		goto out_no_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	if (tcon->nocase)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 		sb->s_d_op = &cifs_ci_dentry_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 		sb->s_d_op = &cifs_dentry_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	sb->s_root = d_make_root(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	if (!sb->s_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 		goto out_no_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) #ifdef CONFIG_CIFS_NFSD_EXPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 		cifs_dbg(FYI, "export ops supported\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 		sb->s_export_op = &cifs_export_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) #endif /* CONFIG_CIFS_NFSD_EXPORT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) out_no_root:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	cifs_dbg(VFS, "%s: get root inode failed\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) static void cifs_kill_sb(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	kill_anon_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	cifs_umount(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	struct super_block *sb = dentry->d_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	struct TCP_Server_Info *server = tcon->ses->server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	unsigned int xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	xid = get_xid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	if (le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength) > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 		buf->f_namelen =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 		       le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 		buf->f_namelen = PATH_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	buf->f_fsid.val[0] = tcon->vol_serial_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	/* are using part of create time for more randomness, see man statfs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	buf->f_fsid.val[1] =  (int)le64_to_cpu(tcon->vol_create_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	buf->f_files = 0;	/* undefined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	buf->f_ffree = 0;	/* unlimited */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 	if (server->ops->queryfs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 		rc = server->ops->queryfs(xid, tcon, cifs_sb, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	free_xid(xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	struct TCP_Server_Info *server = tcon->ses->server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	if (server->ops->fallocate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 		return server->ops->fallocate(file, tcon, mode, off, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) static int cifs_permission(struct inode *inode, int mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	struct cifs_sb_info *cifs_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	cifs_sb = CIFS_SB(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 		if ((mask & MAY_EXEC) && !execute_ok(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 			return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	} else /* file mode might have been restricted at mount time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 		on the client (above and beyond ACL on servers) for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 		servers which do not support setting and viewing mode bits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 		so allowing client to check permissions is useful */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 		return generic_permission(inode, mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) static struct kmem_cache *cifs_inode_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) static struct kmem_cache *cifs_req_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) static struct kmem_cache *cifs_mid_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) static struct kmem_cache *cifs_sm_req_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) mempool_t *cifs_sm_req_poolp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) mempool_t *cifs_req_poolp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) mempool_t *cifs_mid_poolp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) static struct inode *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) cifs_alloc_inode(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	struct cifsInodeInfo *cifs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 	cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	if (!cifs_inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	cifs_inode->cifsAttrs = 0x20;	/* default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	cifs_inode->time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	 * Until the file is open and we have gotten oplock info back from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	 * server, can not assume caching of file data or metadata.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	cifs_set_oplock_level(cifs_inode, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	cifs_inode->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	spin_lock_init(&cifs_inode->writers_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	cifs_inode->writers = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	cifs_inode->vfs_inode.i_blkbits = 14;  /* 2**14 = CIFS_MAX_MSGSIZE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	cifs_inode->server_eof = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	cifs_inode->uniqueid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	cifs_inode->createtime = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	cifs_inode->epoch = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 	spin_lock_init(&cifs_inode->open_file_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	generate_random_uuid(cifs_inode->lease_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	 * Can not set i_flags here - they get immediately overwritten to zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	 * by the VFS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	/* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	INIT_LIST_HEAD(&cifs_inode->openFileList);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	INIT_LIST_HEAD(&cifs_inode->llist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 	return &cifs_inode->vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) cifs_free_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) cifs_evict_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	truncate_inode_pages_final(&inode->i_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	clear_inode(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	cifs_fscache_release_inode_cookie(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) cifs_show_address(struct seq_file *s, struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 	struct sockaddr_in *sa = (struct sockaddr_in *) &server->dstaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) &server->dstaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	seq_puts(s, ",addr=");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 	switch (server->dstaddr.ss_family) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	case AF_INET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		seq_printf(s, "%pI4", &sa->sin_addr.s_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	case AF_INET6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 		seq_printf(s, "%pI6", &sa6->sin6_addr.s6_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 		if (sa6->sin6_scope_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 			seq_printf(s, "%%%u", sa6->sin6_scope_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 		seq_puts(s, "(unknown)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	if (server->rdma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 		seq_puts(s, ",rdma");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) cifs_show_security(struct seq_file *s, struct cifs_ses *ses)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	if (ses->sectype == Unspecified) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 		if (ses->user_name == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 			seq_puts(s, ",sec=none");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 	seq_puts(s, ",sec=");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	switch (ses->sectype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	case LANMAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		seq_puts(s, "lanman");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 	case NTLMv2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 		seq_puts(s, "ntlmv2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 	case NTLM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 		seq_puts(s, "ntlm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	case Kerberos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 		seq_puts(s, "krb5");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	case RawNTLMSSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 		seq_puts(s, "ntlmssp");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 		/* shouldn't ever happen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		seq_puts(s, "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	if (ses->sign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 		seq_puts(s, "i");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	if (ses->sectype == Kerberos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 		seq_printf(s, ",cruid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 			   from_kuid_munged(&init_user_ns, ses->cred_uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	seq_puts(s, ",cache=");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 		seq_puts(s, "strict");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 		seq_puts(s, "none");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 	else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 		seq_puts(s, "singleclient"); /* assume only one client access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 	else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 		seq_puts(s, "ro"); /* read only caching assumed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 		seq_puts(s, "loose");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) cifs_show_nls(struct seq_file *s, struct nls_table *cur)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	struct nls_table *def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	/* Display iocharset= option if it's not default charset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	def = load_nls_default();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	if (def != cur)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 		seq_printf(s, ",iocharset=%s", cur->charset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	unload_nls(def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474)  * cifs_show_options() is for displaying mount options in /proc/mounts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475)  * Not all settable options are displayed but most of the important
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476)  * ones are.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) cifs_show_options(struct seq_file *s, struct dentry *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	struct sockaddr *srcaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	seq_show_option(s, "vers", tcon->ses->server->vals->version_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	cifs_show_security(s, tcon->ses);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	cifs_show_cache_flavor(s, cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	if (tcon->no_lease)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 		seq_puts(s, ",nolease");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 		seq_puts(s, ",multiuser");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	else if (tcon->ses->user_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 		seq_show_option(s, "username", tcon->ses->user_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	if (tcon->ses->domainName && tcon->ses->domainName[0] != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 		seq_show_option(s, "domain", tcon->ses->domainName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	if (srcaddr->sa_family != AF_UNSPEC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		struct sockaddr_in *saddr4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 		struct sockaddr_in6 *saddr6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 		saddr4 = (struct sockaddr_in *)srcaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 		saddr6 = (struct sockaddr_in6 *)srcaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 		if (srcaddr->sa_family == AF_INET6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 			seq_printf(s, ",srcaddr=%pI6c",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 				   &saddr6->sin6_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 		else if (srcaddr->sa_family == AF_INET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 			seq_printf(s, ",srcaddr=%pI4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 				   &saddr4->sin_addr.s_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 			seq_printf(s, ",srcaddr=BAD-AF:%i",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 				   (int)(srcaddr->sa_family));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	seq_printf(s, ",uid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 		   from_kuid_munged(&init_user_ns, cifs_sb->mnt_uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 		seq_puts(s, ",forceuid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		seq_puts(s, ",noforceuid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 	seq_printf(s, ",gid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 		   from_kgid_munged(&init_user_ns, cifs_sb->mnt_gid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 		seq_puts(s, ",forcegid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		seq_puts(s, ",noforcegid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 	cifs_show_address(s, tcon->ses->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	if (!tcon->unix_ext)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 		seq_printf(s, ",file_mode=0%ho,dir_mode=0%ho",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 					   cifs_sb->mnt_file_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 					   cifs_sb->mnt_dir_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	cifs_show_nls(s, cifs_sb->local_nls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	if (tcon->seal)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 		seq_puts(s, ",seal");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	else if (tcon->ses->server->ignore_signature)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 		seq_puts(s, ",signloosely");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	if (tcon->nocase)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 		seq_puts(s, ",nocase");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	if (tcon->nodelete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 		seq_puts(s, ",nodelete");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 	if (tcon->local_lease)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 		seq_puts(s, ",locallease");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	if (tcon->retry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 		seq_puts(s, ",hard");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 		seq_puts(s, ",soft");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	if (tcon->use_persistent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 		seq_puts(s, ",persistenthandles");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	else if (tcon->use_resilient)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 		seq_puts(s, ",resilienthandles");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 	if (tcon->posix_extensions)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 		seq_puts(s, ",posix");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	else if (tcon->unix_ext)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 		seq_puts(s, ",unix");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 		seq_puts(s, ",nounix");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 		seq_puts(s, ",nodfs");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 		seq_puts(s, ",posixpaths");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 		seq_puts(s, ",setuids");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 		seq_puts(s, ",idsfromsid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 		seq_puts(s, ",serverino");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 		seq_puts(s, ",rwpidforward");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 		seq_puts(s, ",forcemand");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 		seq_puts(s, ",nouser_xattr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 		seq_puts(s, ",mapchars");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 		seq_puts(s, ",mapposix");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 		seq_puts(s, ",sfu");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 		seq_puts(s, ",nobrl");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_HANDLE_CACHE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 		seq_puts(s, ",nohandlecache");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 		seq_puts(s, ",modefromsid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 		seq_puts(s, ",cifsacl");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 		seq_puts(s, ",dynperm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	if (root->d_sb->s_flags & SB_POSIXACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 		seq_puts(s, ",acl");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 		seq_puts(s, ",mfsymlinks");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 		seq_puts(s, ",fsc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 		seq_puts(s, ",nostrictsync");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		seq_puts(s, ",noperm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 		seq_printf(s, ",backupuid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 			   from_kuid_munged(&init_user_ns,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 					    cifs_sb->mnt_backupuid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 		seq_printf(s, ",backupgid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 			   from_kgid_munged(&init_user_ns,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 					    cifs_sb->mnt_backupgid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	seq_printf(s, ",rsize=%u", cifs_sb->rsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 	seq_printf(s, ",wsize=%u", cifs_sb->wsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 	seq_printf(s, ",bsize=%u", cifs_sb->bsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	if (tcon->ses->server->min_offload)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 		seq_printf(s, ",esize=%u", tcon->ses->server->min_offload);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	seq_printf(s, ",echo_interval=%lu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 			tcon->ses->server->echo_interval / HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	/* Only display max_credits if it was overridden on mount */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	if (tcon->ses->server->max_credits != SMB2_MAX_CREDITS_AVAILABLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 		seq_printf(s, ",max_credits=%u", tcon->ses->server->max_credits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	if (tcon->snapshot_time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	if (tcon->handle_timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 		seq_printf(s, ",handletimeout=%u", tcon->handle_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 	/* convert actimeo and display it in seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	if (tcon->ses->chan_max > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 		seq_printf(s, ",multichannel,max_channels=%zu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 			   tcon->ses->chan_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) static void cifs_umount_begin(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	if (cifs_sb == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	tcon = cifs_sb_master_tcon(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	spin_lock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		/* we have other mounts to same share or we have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 		   already tried to force umount this and woken up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 		   all waiting network requests, nothing to do */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 		spin_unlock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 	} else if (tcon->tc_count == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 		tcon->tidStatus = CifsExiting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	spin_unlock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	/* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	/* cancel_notify_requests(tcon); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	if (tcon->ses && tcon->ses->server) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 		cifs_dbg(FYI, "wake up tasks now - umount begin not complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 		wake_up_all(&tcon->ses->server->request_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 		wake_up_all(&tcon->ses->server->response_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 		msleep(1); /* yield */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		/* we have to kick the requests once more */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 		wake_up_all(&tcon->ses->server->response_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 		msleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) static int cifs_show_stats(struct seq_file *s, struct dentry *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	/* BB FIXME */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) static int cifs_remount(struct super_block *sb, int *flags, char *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	sync_filesystem(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	*flags |= SB_NODIRATIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) static int cifs_drop_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	/* no serverino => unconditional eviction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 		generic_drop_inode(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) static const struct super_operations cifs_super_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 	.statfs = cifs_statfs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	.alloc_inode = cifs_alloc_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 	.free_inode = cifs_free_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	.drop_inode	= cifs_drop_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 	.evict_inode	= cifs_evict_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) /*	.delete_inode	= cifs_delete_inode,  */  /* Do not need above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	function unless later we add lazy close of inodes or unless the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	kernel forgets to call us with the same number of releases (closes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	as opens */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	.show_options = cifs_show_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	.umount_begin   = cifs_umount_begin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	.remount_fs = cifs_remount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	.show_stats = cifs_show_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719)  * Get root dentry from superblock according to prefix path mount option.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720)  * Return dentry with refcount + 1 on success and NULL otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) static struct dentry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) cifs_get_root(struct smb_vol *vol, struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	char *full_path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	char *s, *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	char sep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 		return dget(sb->s_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	full_path = cifs_build_path_to_root(vol, cifs_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 				cifs_sb_master_tcon(cifs_sb), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	if (full_path == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 		return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	cifs_dbg(FYI, "Get root dentry for %s\n", full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	sep = CIFS_DIR_SEP(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	dentry = dget(sb->s_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	p = s = full_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 		struct inode *dir = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 		struct dentry *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 		if (!S_ISDIR(dir->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 			dput(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 			dentry = ERR_PTR(-ENOTDIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 		/* skip separators */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 		while (*s == sep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 			s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 		if (!*s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 		p = s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 		/* next separator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 		while (*s && *s != sep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 			s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 		child = lookup_positive_unlocked(p, dentry, s - p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 		dput(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 		dentry = child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	} while (!IS_ERR(dentry));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	kfree(full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	return dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) static int cifs_set_super(struct super_block *sb, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	struct cifs_mnt_data *mnt_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	sb->s_fs_info = mnt_data->cifs_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	return set_anon_super(sb, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) static struct dentry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) cifs_smb3_do_mount(struct file_system_type *fs_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	      int flags, const char *dev_name, void *data, bool is_smb3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	struct super_block *sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	struct cifs_sb_info *cifs_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	struct smb_vol *volume_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	struct cifs_mnt_data mnt_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	struct dentry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	 * Prints in Kernel / CIFS log the attempted mount operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	 *	If CIFS_DEBUG && cifs_FYI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	if (cifsFYI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 		cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 		cifs_info("Attempting to mount %s\n", dev_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	volume_info = cifs_get_volume_info((char *)data, dev_name, is_smb3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	if (IS_ERR(volume_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 		return ERR_CAST(volume_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	if (cifs_sb == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		root = ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 		goto out_nls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	if (cifs_sb->mountdata == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 		root = ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	rc = cifs_setup_cifs_sb(volume_info, cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 		root = ERR_PTR(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	rc = cifs_mount(cifs_sb, volume_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 		if (!(flags & SB_SILENT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 			cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 				 rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 		root = ERR_PTR(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	mnt_data.vol = volume_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 	mnt_data.cifs_sb = cifs_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	mnt_data.flags = flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	/* BB should we make this contingent on mount parm? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	flags |= SB_NODIRATIME | SB_NOATIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 	sb = sget(fs_type, cifs_match_super, cifs_set_super, flags, &mnt_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	if (IS_ERR(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		root = ERR_CAST(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 		cifs_umount(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	if (sb->s_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 		cifs_dbg(FYI, "Use existing superblock\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 		cifs_umount(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 		rc = cifs_read_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 		if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 			root = ERR_PTR(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 			goto out_super;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 		sb->s_flags |= SB_ACTIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	root = cifs_get_root(volume_info, sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	if (IS_ERR(root))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 		goto out_super;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 	cifs_dbg(FYI, "dentry root is: %p\n", root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) out_super:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	deactivate_locked_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	return root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	cifs_cleanup_volume_info(volume_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	return root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	kfree(cifs_sb->prepath);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	kfree(cifs_sb->mountdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	kfree(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) out_nls:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	unload_nls(volume_info->local_nls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) static struct dentry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) smb3_do_mount(struct file_system_type *fs_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 	      int flags, const char *dev_name, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	return cifs_smb3_do_mount(fs_type, flags, dev_name, data, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) static struct dentry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) cifs_do_mount(struct file_system_type *fs_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	      int flags, const char *dev_name, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	return cifs_smb3_do_mount(fs_type, flags, dev_name, data, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 	ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	struct inode *inode = file_inode(iocb->ki_filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	if (iocb->ki_filp->f_flags & O_DIRECT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 		return cifs_user_readv(iocb, iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 	rc = cifs_revalidate_mapping(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	return generic_file_read_iter(iocb, iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	struct inode *inode = file_inode(iocb->ki_filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 	struct cifsInodeInfo *cinode = CIFS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	ssize_t written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 	if (iocb->ki_filp->f_flags & O_DIRECT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 		written = cifs_user_writev(iocb, from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 		if (written > 0 && CIFS_CACHE_READ(cinode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 			cifs_zap_mapping(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 			cifs_dbg(FYI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 				 "Set no oplock for inode=%p after a write operation\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 				 inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 			cinode->oplock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 		return written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	written = cifs_get_writer(cinode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	if (written)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 		return written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	written = generic_file_write_iter(iocb, from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 	if (CIFS_CACHE_WRITE(CIFS_I(inode)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	rc = filemap_fdatawrite(inode->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 		cifs_dbg(FYI, "cifs_file_write_iter: %d rc on %p inode\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 			 rc, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	cifs_put_writer(cinode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	return written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	struct cifsFileInfo *cfile = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	 * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	 * the cached file length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	if (whence != SEEK_SET && whence != SEEK_CUR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 		int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 		struct inode *inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 		 * We need to be sure that all dirty pages are written and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 		 * server has the newest file length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 		if (!CIFS_CACHE_READ(CIFS_I(inode)) && inode->i_mapping &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 		    inode->i_mapping->nrpages != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 			rc = filemap_fdatawait(inode->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 			if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 				mapping_set_error(inode->i_mapping, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 				return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 		 * Some applications poll for the file length in this strange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 		 * way so we must seek to end on non-oplocked files by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		 * setting the revalidate time to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 		CIFS_I(inode)->time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 		rc = cifs_revalidate_file_attr(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 		if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 			return (loff_t)rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	if (cfile && cfile->tlink) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 		tcon = tlink_tcon(cfile->tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 		if (tcon->ses->server->ops->llseek)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 			return tcon->ses->server->ops->llseek(file, tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 							      offset, whence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	return generic_file_llseek(file, offset, whence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) cifs_setlease(struct file *file, long arg, struct file_lock **lease, void **priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 	 * Note that this is called by vfs setlease with i_lock held to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	 * protect *lease from going away.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	struct inode *inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	struct cifsFileInfo *cfile = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	if (!(S_ISREG(inode->i_mode)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	/* Check if file is oplocked if this is request for new lease */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	if (arg == F_UNLCK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	    ((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	    ((arg == F_WRLCK) && CIFS_CACHE_WRITE(CIFS_I(inode))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 		return generic_setlease(file, arg, lease, priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	else if (tlink_tcon(cfile->tlink)->local_lease &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 		 !CIFS_CACHE_READ(CIFS_I(inode)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 		 * If the server claims to support oplock on this file, then we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 		 * still need to check oplock even if the local_lease mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 		 * option is set, but there are servers which do not support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 		 * oplock for which this mount option may be useful if the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 		 * knows that the file won't be changed on the server by anyone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 		 * else.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 		return generic_setlease(file, arg, lease, priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) struct file_system_type cifs_fs_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	.name = "cifs",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	.mount = cifs_do_mount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	.kill_sb = cifs_kill_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	.fs_flags = FS_RENAME_DOES_D_MOVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) MODULE_ALIAS_FS("cifs");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) static struct file_system_type smb3_fs_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	.name = "smb3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	.mount = smb3_do_mount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	.kill_sb = cifs_kill_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	.fs_flags = FS_RENAME_DOES_D_MOVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) MODULE_ALIAS_FS("smb3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) MODULE_ALIAS("smb3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) const struct inode_operations cifs_dir_inode_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 	.create = cifs_create,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	.atomic_open = cifs_atomic_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 	.lookup = cifs_lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 	.getattr = cifs_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	.unlink = cifs_unlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 	.link = cifs_hardlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	.mkdir = cifs_mkdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	.rmdir = cifs_rmdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	.rename = cifs_rename2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	.permission = cifs_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	.setattr = cifs_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 	.symlink = cifs_symlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	.mknod   = cifs_mknod,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	.listxattr = cifs_listxattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) const struct inode_operations cifs_file_inode_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	.setattr = cifs_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	.getattr = cifs_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	.permission = cifs_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	.listxattr = cifs_listxattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 	.fiemap = cifs_fiemap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) const struct inode_operations cifs_symlink_inode_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	.get_link = cifs_get_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	.permission = cifs_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	.listxattr = cifs_listxattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 		struct file *dst_file, loff_t destoff, loff_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 		unsigned int remap_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 	struct inode *src_inode = file_inode(src_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 	struct inode *target_inode = file_inode(dst_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	struct cifsFileInfo *smb_file_src = src_file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 	struct cifsFileInfo *smb_file_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 	struct cifs_tcon *target_tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	unsigned int xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	cifs_dbg(FYI, "clone range\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 	xid = get_xid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 	if (!src_file->private_data || !dst_file->private_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 		rc = -EBADF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 		cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	smb_file_target = dst_file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	target_tcon = tlink_tcon(smb_file_target->tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	 * Note: cifs case is easier than btrfs since server responsible for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	 * checks for proper open modes and file type and if it wants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	 * server could even support copy of range where source = target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 	lock_two_nondirectories(target_inode, src_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 	if (len == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 		len = src_inode->i_size - off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	cifs_dbg(FYI, "about to flush pages\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	/* should we flush first and last page first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	truncate_inode_pages_range(&target_inode->i_data, destoff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 				   PAGE_ALIGN(destoff + len)-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 	if (target_tcon->ses->server->ops->duplicate_extents)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 		rc = target_tcon->ses->server->ops->duplicate_extents(xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 			smb_file_src, smb_file_target, off, len, destoff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 		rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 	/* force revalidate of size and timestamps of target file now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	   that target is updated on the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 	CIFS_I(target_inode)->time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 	/* although unlocking in the reverse order from locking is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 	   strictly necessary here it is a little cleaner to be consistent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	unlock_two_nondirectories(src_inode, target_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 	free_xid(xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 	return rc < 0 ? rc : len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) ssize_t cifs_file_copychunk_range(unsigned int xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 				struct file *src_file, loff_t off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 				struct file *dst_file, loff_t destoff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 				size_t len, unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 	struct inode *src_inode = file_inode(src_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 	struct inode *target_inode = file_inode(dst_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	struct cifsFileInfo *smb_file_src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 	struct cifsFileInfo *smb_file_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 	struct cifs_tcon *src_tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 	struct cifs_tcon *target_tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 	ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	cifs_dbg(FYI, "copychunk range\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	if (!src_file->private_data || !dst_file->private_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 		rc = -EBADF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 		cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	rc = -EXDEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 	smb_file_target = dst_file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 	smb_file_src = src_file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	src_tcon = tlink_tcon(smb_file_src->tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	target_tcon = tlink_tcon(smb_file_target->tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	if (src_tcon->ses != target_tcon->ses) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 		cifs_dbg(VFS, "source and target of copy not on same server\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	rc = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 	if (!target_tcon->ses->server->ops->copychunk_range)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	 * Note: cifs case is easier than btrfs since server responsible for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	 * checks for proper open modes and file type and if it wants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 	 * server could even support copy of range where source = target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	lock_two_nondirectories(target_inode, src_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	cifs_dbg(FYI, "about to flush pages\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	/* should we flush first and last page first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 	truncate_inode_pages(&target_inode->i_data, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	rc = file_modified(dst_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 		rc = target_tcon->ses->server->ops->copychunk_range(xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 			smb_file_src, smb_file_target, off, len, destoff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 	file_accessed(src_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 	/* force revalidate of size and timestamps of target file now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	 * that target is updated on the server
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 	CIFS_I(target_inode)->time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	/* although unlocking in the reverse order from locking is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	 * strictly necessary here it is a little cleaner to be consistent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	unlock_two_nondirectories(src_inode, target_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205)  * Directory operations under CIFS/SMB2/SMB3 are synchronous, so fsync()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206)  * is a dummy operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) static int cifs_dir_fsync(struct file *file, loff_t start, loff_t end, int datasync)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	cifs_dbg(FYI, "Sync directory - name: %pD datasync: 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 		 file, datasync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 				struct file *dst_file, loff_t destoff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 				size_t len, unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	unsigned int xid = get_xid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 	ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	struct cifsFileInfo *cfile = dst_file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 	if (cfile->swapfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 					len, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	free_xid(xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 	if (rc == -EOPNOTSUPP || rc == -EXDEV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 		rc = generic_copy_file_range(src_file, off, dst_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 					     destoff, len, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) const struct file_operations cifs_file_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	.read_iter = cifs_loose_read_iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 	.write_iter = cifs_file_write_iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	.open = cifs_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	.release = cifs_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	.lock = cifs_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	.flock = cifs_flock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	.fsync = cifs_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	.flush = cifs_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	.mmap  = cifs_file_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	.splice_read = generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	.splice_write = iter_file_splice_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	.llseek = cifs_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 	.unlocked_ioctl	= cifs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 	.copy_file_range = cifs_copy_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 	.remap_file_range = cifs_remap_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 	.setlease = cifs_setlease,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 	.fallocate = cifs_fallocate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) const struct file_operations cifs_file_strict_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	.read_iter = cifs_strict_readv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	.write_iter = cifs_strict_writev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	.open = cifs_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	.release = cifs_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 	.lock = cifs_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 	.flock = cifs_flock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	.fsync = cifs_strict_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 	.flush = cifs_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 	.mmap = cifs_file_strict_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	.splice_read = generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	.splice_write = iter_file_splice_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	.llseek = cifs_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	.unlocked_ioctl	= cifs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 	.copy_file_range = cifs_copy_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 	.remap_file_range = cifs_remap_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 	.setlease = cifs_setlease,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 	.fallocate = cifs_fallocate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) const struct file_operations cifs_file_direct_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 	.read_iter = cifs_direct_readv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	.write_iter = cifs_direct_writev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 	.open = cifs_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 	.release = cifs_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 	.lock = cifs_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) 	.flock = cifs_flock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 	.fsync = cifs_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 	.flush = cifs_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 	.mmap = cifs_file_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 	.splice_read = generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	.splice_write = iter_file_splice_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	.unlocked_ioctl  = cifs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	.copy_file_range = cifs_copy_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 	.remap_file_range = cifs_remap_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 	.llseek = cifs_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 	.setlease = cifs_setlease,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	.fallocate = cifs_fallocate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) const struct file_operations cifs_file_nobrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 	.read_iter = cifs_loose_read_iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 	.write_iter = cifs_file_write_iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	.open = cifs_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) 	.release = cifs_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 	.fsync = cifs_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 	.flush = cifs_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 	.mmap  = cifs_file_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 	.splice_read = generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	.splice_write = iter_file_splice_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 	.llseek = cifs_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 	.unlocked_ioctl	= cifs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 	.copy_file_range = cifs_copy_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 	.remap_file_range = cifs_remap_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 	.setlease = cifs_setlease,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 	.fallocate = cifs_fallocate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) const struct file_operations cifs_file_strict_nobrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 	.read_iter = cifs_strict_readv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	.write_iter = cifs_strict_writev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 	.open = cifs_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 	.release = cifs_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 	.fsync = cifs_strict_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	.flush = cifs_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	.mmap = cifs_file_strict_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	.splice_read = generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	.splice_write = iter_file_splice_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	.llseek = cifs_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	.unlocked_ioctl	= cifs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	.copy_file_range = cifs_copy_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	.remap_file_range = cifs_remap_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	.setlease = cifs_setlease,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 	.fallocate = cifs_fallocate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) const struct file_operations cifs_file_direct_nobrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	.read_iter = cifs_direct_readv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 	.write_iter = cifs_direct_writev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	.open = cifs_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 	.release = cifs_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	.fsync = cifs_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 	.flush = cifs_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	.mmap = cifs_file_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 	.splice_read = generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 	.splice_write = iter_file_splice_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 	.unlocked_ioctl  = cifs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	.copy_file_range = cifs_copy_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 	.remap_file_range = cifs_remap_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 	.llseek = cifs_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	.setlease = cifs_setlease,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 	.fallocate = cifs_fallocate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) const struct file_operations cifs_dir_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	.iterate_shared = cifs_readdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	.release = cifs_closedir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 	.read    = generic_read_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 	.unlocked_ioctl  = cifs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	.copy_file_range = cifs_copy_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	.remap_file_range = cifs_remap_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	.llseek = generic_file_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 	.fsync = cifs_dir_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) cifs_init_once(void *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 	struct cifsInodeInfo *cifsi = inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	inode_init_once(&cifsi->vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 	init_rwsem(&cifsi->lock_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) static int __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) cifs_init_inodecache(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 					      sizeof(struct cifsInodeInfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 					      0, (SLAB_RECLAIM_ACCOUNT|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 						SLAB_MEM_SPREAD|SLAB_ACCOUNT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 					      cifs_init_once);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 	if (cifs_inode_cachep == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) cifs_destroy_inodecache(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 	 * Make sure all delayed rcu free inodes are flushed before we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 	 * destroy cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 	rcu_barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	kmem_cache_destroy(cifs_inode_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) cifs_init_request_bufs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 	 * SMB2 maximum header size is bigger than CIFS one - no problems to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 	 * allocate some more bytes for CIFS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 	size_t max_hdr_size = MAX_SMB2_HDR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	if (CIFSMaxBufSize < 8192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	/* Buffer size can not be smaller than 2 * PATH_MAX since maximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 	Unicode path name has to fit in any SMB/CIFS path based frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 		CIFSMaxBufSize = 8192;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 	} else if (CIFSMaxBufSize > 1024*127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 		CIFSMaxBufSize = 1024 * 127;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 		CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 	cifs_dbg(VFS, "CIFSMaxBufSize %d 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 		 CIFSMaxBufSize, CIFSMaxBufSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 	cifs_req_cachep = kmem_cache_create_usercopy("cifs_request",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 					    CIFSMaxBufSize + max_hdr_size, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 					    SLAB_HWCACHE_ALIGN, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 					    CIFSMaxBufSize + max_hdr_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 					    NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 	if (cifs_req_cachep == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 	if (cifs_min_rcv < 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 		cifs_min_rcv = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 	else if (cifs_min_rcv > 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 		cifs_min_rcv = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 		cifs_dbg(VFS, "cifs_min_rcv set to maximum (64)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 	cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 						  cifs_req_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 	if (cifs_req_poolp == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 		kmem_cache_destroy(cifs_req_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 	/* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 	almost all handle based requests (but not write response, nor is it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 	sufficient for path based requests).  A smaller size would have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 	been more efficient (compacting multiple slab items on one 4k page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 	for the case in which debug was on, but this larger size allows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 	more SMBs to use small buffer alloc and is still much more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 	efficient to alloc 1 per page off the slab compared to 17K (5page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 	alloc of large cifs buffers even when page debugging is on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 	cifs_sm_req_cachep = kmem_cache_create_usercopy("cifs_small_rq",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 			MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 			0, MAX_CIFS_SMALL_BUFFER_SIZE, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 	if (cifs_sm_req_cachep == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 		mempool_destroy(cifs_req_poolp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 		kmem_cache_destroy(cifs_req_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 	if (cifs_min_small < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 		cifs_min_small = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 	else if (cifs_min_small > 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 		cifs_min_small = 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 		cifs_dbg(FYI, "cifs_min_small set to maximum (256)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 	cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 						     cifs_sm_req_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 	if (cifs_sm_req_poolp == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 		mempool_destroy(cifs_req_poolp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 		kmem_cache_destroy(cifs_req_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 		kmem_cache_destroy(cifs_sm_req_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) cifs_destroy_request_bufs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 	mempool_destroy(cifs_req_poolp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 	kmem_cache_destroy(cifs_req_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 	mempool_destroy(cifs_sm_req_poolp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 	kmem_cache_destroy(cifs_sm_req_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) cifs_init_mids(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 	cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 					    sizeof(struct mid_q_entry), 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 					    SLAB_HWCACHE_ALIGN, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 	if (cifs_mid_cachep == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 	/* 3 is a reasonable minimum number of simultaneous operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 	cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 	if (cifs_mid_poolp == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 		kmem_cache_destroy(cifs_mid_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) cifs_destroy_mids(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 	mempool_destroy(cifs_mid_poolp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 	kmem_cache_destroy(cifs_mid_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) static int __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) init_cifs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) 	int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 	cifs_proc_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 	INIT_LIST_HEAD(&cifs_tcp_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 	INIT_LIST_HEAD(&GlobalDnotifyReqList);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 	INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) #endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523)  *  Initialize Global counters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 	atomic_set(&sesInfoAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 	atomic_set(&tconInfoAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 	atomic_set(&tcpSesAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 	atomic_set(&tcpSesReconnectCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	atomic_set(&tconInfoReconnectCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 	atomic_set(&bufAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 	atomic_set(&smBufAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 	atomic_set(&totBufAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 	atomic_set(&totSmBufAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 	if (slow_rsp_threshold < 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 		cifs_dbg(FYI, "slow_response_threshold msgs disabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 	else if (slow_rsp_threshold > 32767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 		cifs_dbg(VFS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 		       "slow response threshold set higher than recommended (0 to 32767)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) #endif /* CONFIG_CIFS_STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 	atomic_set(&midCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) 	GlobalCurrentXid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 	GlobalTotalActiveXid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 	GlobalMaxActiveXid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 	spin_lock_init(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 	spin_lock_init(&GlobalMid_Lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 	cifs_lock_secret = get_random_u32();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 	if (cifs_max_pending < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 		cifs_max_pending = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 		cifs_dbg(FYI, "cifs_max_pending set to min of 2\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 	} else if (cifs_max_pending > CIFS_MAX_REQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 		cifs_max_pending = CIFS_MAX_REQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 		cifs_dbg(FYI, "cifs_max_pending set to max of %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 			 CIFS_MAX_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 	cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 	if (!cifsiod_wq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 		goto out_clean_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) 	 * Consider in future setting limit!=0 maybe to min(num_of_cores - 1, 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 	 * so that we don't launch too many worker threads but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) 	 * Documentation/core-api/workqueue.rst recommends setting it to 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) 	/* WQ_UNBOUND allows decrypt tasks to run on any CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 	decrypt_wq = alloc_workqueue("smb3decryptd",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) 				     WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) 	if (!decrypt_wq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) 		goto out_destroy_cifsiod_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) 	fileinfo_put_wq = alloc_workqueue("cifsfileinfoput",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 				     WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) 	if (!fileinfo_put_wq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 		goto out_destroy_decrypt_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) 	cifsoplockd_wq = alloc_workqueue("cifsoplockd",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 					 WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) 	if (!cifsoplockd_wq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) 		goto out_destroy_fileinfo_put_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) 	rc = cifs_fscache_register();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) 		goto out_destroy_cifsoplockd_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 	rc = cifs_init_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) 		goto out_unreg_fscache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 	rc = cifs_init_mids();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 		goto out_destroy_inodecache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 	rc = cifs_init_request_bufs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 		goto out_destroy_mids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) 	rc = dfs_cache_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) 		goto out_destroy_request_bufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) #endif /* CONFIG_CIFS_DFS_UPCALL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) #ifdef CONFIG_CIFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) 	rc = init_cifs_spnego();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) 		goto out_destroy_dfs_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) #endif /* CONFIG_CIFS_UPCALL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 	rc = init_cifs_idmap();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 		goto out_register_key_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 	rc = register_filesystem(&cifs_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 		goto out_init_cifs_idmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) 	rc = register_filesystem(&smb3_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 	if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) 		unregister_filesystem(&cifs_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) 		goto out_init_cifs_idmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) out_init_cifs_idmap:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) 	exit_cifs_idmap();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) out_register_key_type:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) #ifdef CONFIG_CIFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) 	exit_cifs_spnego();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) out_destroy_dfs_cache:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) 	dfs_cache_destroy();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) out_destroy_request_bufs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) 	cifs_destroy_request_bufs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) out_destroy_mids:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) 	cifs_destroy_mids();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) out_destroy_inodecache:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) 	cifs_destroy_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) out_unreg_fscache:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) 	cifs_fscache_unregister();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) out_destroy_cifsoplockd_wq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) 	destroy_workqueue(cifsoplockd_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) out_destroy_fileinfo_put_wq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 	destroy_workqueue(fileinfo_put_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) out_destroy_decrypt_wq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) 	destroy_workqueue(decrypt_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) out_destroy_cifsiod_wq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) 	destroy_workqueue(cifsiod_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) out_clean_proc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) 	cifs_proc_clean();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) static void __exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) exit_cifs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) 	cifs_dbg(NOISY, "exit_smb3\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) 	unregister_filesystem(&cifs_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) 	unregister_filesystem(&smb3_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) 	cifs_dfs_release_automount_timer();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) 	exit_cifs_idmap();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) #ifdef CONFIG_CIFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) 	exit_cifs_spnego();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) 	dfs_cache_destroy();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) 	cifs_destroy_request_bufs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) 	cifs_destroy_mids();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) 	cifs_destroy_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) 	cifs_fscache_unregister();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) 	destroy_workqueue(cifsoplockd_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) 	destroy_workqueue(decrypt_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) 	destroy_workqueue(fileinfo_put_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) 	destroy_workqueue(cifsiod_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) 	cifs_proc_clean();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) MODULE_AUTHOR("Steve French");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) MODULE_LICENSE("GPL");	/* combination of LGPL + GPL source behaves as GPL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) MODULE_DESCRIPTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) 	("VFS to access SMB3 servers e.g. Samba, Macs, Azure and Windows (and "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) 	"also older servers complying with the SNIA CIFS Specification)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) MODULE_VERSION(CIFS_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) MODULE_SOFTDEP("ecb");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) MODULE_SOFTDEP("hmac");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) MODULE_SOFTDEP("md4");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) MODULE_SOFTDEP("md5");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) MODULE_SOFTDEP("nls");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) MODULE_SOFTDEP("aes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) MODULE_SOFTDEP("cmac");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) MODULE_SOFTDEP("sha256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) MODULE_SOFTDEP("sha512");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) MODULE_SOFTDEP("aead2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) MODULE_SOFTDEP("ccm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) MODULE_SOFTDEP("gcm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) module_init(init_cifs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) module_exit(exit_cifs)