Skip to content

Commit 851f657

Browse files
committed
Merge tag '6.2-rc-smb3-client-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs client updates from Steve French: - SMB3.1.1 POSIX Extensions fixes - remove use of generic_writepages() and ->cifs_writepage(), in favor of ->cifs_writepages() and ->migrate_folio() - memory management fixes - mount parm parsing fixes - minor cleanup fixes * tag '6.2-rc-smb3-client-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6: cifs: Remove duplicated include in cifsglob.h cifs: fix oops during encryption cifs: print warning when conflicting soft vs. hard mount options specified cifs: fix missing display of three mount options cifs: fix various whitespace errors in headers cifs: minor cleanup of some headers cifs: skip alloc when request has no pages cifs: remove ->writepage cifs: stop using generic_writepages cifs: wire up >migrate_folio cifs: Parse owner/group for stat in smb311 posix extensions cifs: Add "extbuf" and "extbuflen" args to smb2_compound_op() Fix path in cifs/usage.rst
2 parents ec9187e + d74f4a3 commit 851f657

File tree

14 files changed

+298
-166
lines changed

14 files changed

+298
-166
lines changed

Documentation/admin-guide/cifs/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ CIFS kernel module parameters
858858
These module parameters can be specified or modified either during the time of
859859
module loading or during the runtime by using the interface::
860860

861-
/proc/module/cifs/parameters/<param>
861+
/sys/module/cifs/parameters/<param>
862862

863863
i.e.::
864864

fs/cifs/cifs_ioctl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct smb3_notify_info {
108108
#define CIFS_IOC_NOTIFY _IOW(CIFS_IOCTL_MAGIC, 9, struct smb3_notify)
109109
#define CIFS_DUMP_FULL_KEY _IOWR(CIFS_IOCTL_MAGIC, 10, struct smb3_full_key_debug_info)
110110
#define CIFS_IOC_NOTIFY_INFO _IOWR(CIFS_IOCTL_MAGIC, 11, struct smb3_notify_info)
111-
#define CIFS_IOC_SHUTDOWN _IOR ('X', 125, __u32)
111+
#define CIFS_IOC_SHUTDOWN _IOR('X', 125, __u32)
112112

113113
/*
114114
* Flags for going down operation

fs/cifs/cifsfs.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,9 +678,15 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
678678
seq_printf(s, ",echo_interval=%lu",
679679
tcon->ses->server->echo_interval / HZ);
680680

681-
/* Only display max_credits if it was overridden on mount */
681+
/* Only display the following if overridden on mount */
682682
if (tcon->ses->server->max_credits != SMB2_MAX_CREDITS_AVAILABLE)
683683
seq_printf(s, ",max_credits=%u", tcon->ses->server->max_credits);
684+
if (tcon->ses->server->tcp_nodelay)
685+
seq_puts(s, ",tcpnodelay");
686+
if (tcon->ses->server->noautotune)
687+
seq_puts(s, ",noautotune");
688+
if (tcon->ses->server->noblocksnd)
689+
seq_puts(s, ",noblocksend");
684690

685691
if (tcon->snapshot_time)
686692
seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);

fs/cifs/cifsfs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ extern int cifs_lock(struct file *, int, struct file_lock *);
105105
extern int cifs_fsync(struct file *, loff_t, loff_t, int);
106106
extern int cifs_strict_fsync(struct file *, loff_t, loff_t, int);
107107
extern int cifs_flush(struct file *, fl_owner_t id);
108-
extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
109-
extern int cifs_file_strict_mmap(struct file * , struct vm_area_struct *);
108+
extern int cifs_file_mmap(struct file *file, struct vm_area_struct *vma);
109+
extern int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma);
110110
extern const struct file_operations cifs_dir_ops;
111111
extern int cifs_dir_open(struct inode *inode, struct file *file);
112112
extern int cifs_readdir(struct file *file, struct dir_context *ctx);

fs/cifs/cifsglob.h

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <linux/in6.h>
1414
#include <linux/inet.h>
1515
#include <linux/slab.h>
16+
#include <linux/scatterlist.h>
17+
#include <linux/mm.h>
1618
#include <linux/mempool.h>
1719
#include <linux/workqueue.h>
1820
#include <linux/utsname.h>
@@ -21,7 +23,6 @@
2123
#include "cifs_fs_sb.h"
2224
#include "cifsacl.h"
2325
#include <crypto/internal/hash.h>
24-
#include <linux/scatterlist.h>
2526
#include <uapi/linux/cifs/cifs_mount.h>
2627
#include "../smbfs_common/smb2pdu.h"
2728
#include "smb2pdu.h"
@@ -785,6 +786,7 @@ static inline unsigned int
785786
in_flight(struct TCP_Server_Info *server)
786787
{
787788
unsigned int num;
789+
788790
spin_lock(&server->req_lock);
789791
num = server->in_flight;
790792
spin_unlock(&server->req_lock);
@@ -795,6 +797,7 @@ static inline bool
795797
has_credits(struct TCP_Server_Info *server, int *credits, int num_credits)
796798
{
797799
int num;
800+
798801
spin_lock(&server->req_lock);
799802
num = *credits;
800803
spin_unlock(&server->req_lock);
@@ -1025,7 +1028,7 @@ struct cifs_ses {
10251028
struct TCP_Server_Info *server; /* pointer to server info */
10261029
int ses_count; /* reference counter */
10271030
enum ses_status_enum ses_status; /* updates protected by cifs_tcp_ses_lock */
1028-
unsigned overrideSecFlg; /* if non-zero override global sec flags */
1031+
unsigned int overrideSecFlg; /* if non-zero override global sec flags */
10291032
char *serverOS; /* name of operating system underlying server */
10301033
char *serverNOS; /* name of network operating system of server */
10311034
char *serverDomain; /* security realm of server */
@@ -1381,7 +1384,7 @@ struct cifsFileInfo {
13811384
__u32 pid; /* process id who opened file */
13821385
struct cifs_fid fid; /* file id from remote */
13831386
struct list_head rlist; /* reconnect list */
1384-
/* BB add lock scope info here if needed */ ;
1387+
/* BB add lock scope info here if needed */
13851388
/* lock scope id (0 if none) */
13861389
struct dentry *dentry;
13871390
struct tcon_link *tlink;
@@ -1769,6 +1772,7 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param,
17691772
int number_of_items)
17701773
{
17711774
int i;
1775+
17721776
if ((number_of_items == 0) || (param == NULL))
17731777
return;
17741778
for (i = 0; i < number_of_items; i++) {
@@ -2137,4 +2141,70 @@ static inline void move_cifs_info_to_smb2(struct smb2_file_all_info *dst, const
21372141
dst->FileNameLength = src->FileNameLength;
21382142
}
21392143

2144+
static inline unsigned int cifs_get_num_sgs(const struct smb_rqst *rqst,
2145+
int num_rqst,
2146+
const u8 *sig)
2147+
{
2148+
unsigned int len, skip;
2149+
unsigned int nents = 0;
2150+
unsigned long addr;
2151+
int i, j;
2152+
2153+
/* Assumes the first rqst has a transform header as the first iov.
2154+
* I.e.
2155+
* rqst[0].rq_iov[0] is transform header
2156+
* rqst[0].rq_iov[1+] data to be encrypted/decrypted
2157+
* rqst[1+].rq_iov[0+] data to be encrypted/decrypted
2158+
*/
2159+
for (i = 0; i < num_rqst; i++) {
2160+
/*
2161+
* The first rqst has a transform header where the
2162+
* first 20 bytes are not part of the encrypted blob.
2163+
*/
2164+
for (j = 0; j < rqst[i].rq_nvec; j++) {
2165+
struct kvec *iov = &rqst[i].rq_iov[j];
2166+
2167+
skip = (i == 0) && (j == 0) ? 20 : 0;
2168+
addr = (unsigned long)iov->iov_base + skip;
2169+
if (unlikely(is_vmalloc_addr((void *)addr))) {
2170+
len = iov->iov_len - skip;
2171+
nents += DIV_ROUND_UP(offset_in_page(addr) + len,
2172+
PAGE_SIZE);
2173+
} else {
2174+
nents++;
2175+
}
2176+
}
2177+
nents += rqst[i].rq_npages;
2178+
}
2179+
nents += DIV_ROUND_UP(offset_in_page(sig) + SMB2_SIGNATURE_SIZE, PAGE_SIZE);
2180+
return nents;
2181+
}
2182+
2183+
/* We can not use the normal sg_set_buf() as we will sometimes pass a
2184+
* stack object as buf.
2185+
*/
2186+
static inline struct scatterlist *cifs_sg_set_buf(struct scatterlist *sg,
2187+
const void *buf,
2188+
unsigned int buflen)
2189+
{
2190+
unsigned long addr = (unsigned long)buf;
2191+
unsigned int off = offset_in_page(addr);
2192+
2193+
addr &= PAGE_MASK;
2194+
if (unlikely(is_vmalloc_addr((void *)addr))) {
2195+
do {
2196+
unsigned int len = min_t(unsigned int, buflen, PAGE_SIZE - off);
2197+
2198+
sg_set_page(sg++, vmalloc_to_page((void *)addr), len, off);
2199+
2200+
off = 0;
2201+
addr += PAGE_SIZE;
2202+
buflen -= len;
2203+
} while (buflen);
2204+
} else {
2205+
sg_set_page(sg++, virt_to_page(addr), buflen, off);
2206+
}
2207+
return sg;
2208+
}
2209+
21402210
#endif /* _CIFS_GLOB_H */

fs/cifs/cifspdu.h

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ typedef struct smb_com_transaction_change_notify_req {
14291429
__u8 WatchTree; /* 1 = Monitor subdirectories */
14301430
__u8 Reserved2;
14311431
__le16 ByteCount;
1432-
/* __u8 Pad[3];*/
1432+
/* __u8 Pad[3];*/
14331433
/* __u8 Data[1];*/
14341434
} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
14351435

@@ -1752,8 +1752,7 @@ struct smb_com_transaction2_sfi_rsp {
17521752
struct smb_hdr hdr; /* wct = 10 + SetupCount */
17531753
struct trans2_resp t2;
17541754
__u16 ByteCount;
1755-
__u16 Reserved2; /* parameter word reserved -
1756-
present for infolevels > 100 */
1755+
__u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
17571756
} __attribute__((packed));
17581757

17591758
struct smb_t2_qfi_req {
@@ -1768,8 +1767,7 @@ struct smb_t2_qfi_rsp {
17681767
struct smb_hdr hdr; /* wct = 10 + SetupCount */
17691768
struct trans2_resp t2;
17701769
__u16 ByteCount;
1771-
__u16 Reserved2; /* parameter word reserved -
1772-
present for infolevels > 100 */
1770+
__u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
17731771
} __attribute__((packed));
17741772

17751773
/*
@@ -2146,13 +2144,11 @@ typedef struct {
21462144
#define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
21472145
calls including posix open
21482146
and posix unlink */
2149-
#define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up
2150-
to 0xFFFF00 */
2147+
#define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up to 0xFFFF00 */
21512148
#define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
21522149
#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */
21532150
#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */
2154-
#define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and
2155-
QFS PROXY call */
2151+
#define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and QFS PROXY call */
21562152
#ifdef CONFIG_CIFS_POSIX
21572153
/* presumably don't need the 0x20 POSIX_PATH_OPS_CAP since we never send
21582154
LockingX instead of posix locking call on unix sess (and we do not expect
@@ -2368,8 +2364,7 @@ typedef struct {
23682364

23692365
struct file_allocation_info {
23702366
__le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
2371-
} __attribute__((packed)); /* size used on disk, for level 0x103 for set,
2372-
0x105 for query */
2367+
} __packed; /* size used on disk, for level 0x103 for set, 0x105 for query */
23732368

23742369
struct file_end_of_file_info {
23752370
__le64 FileSize; /* offset to end of file */
@@ -2409,8 +2404,7 @@ struct cifs_posix_acl { /* access conrol list (ACL) */
24092404
__le16 access_entry_count; /* access ACL - count of entries */
24102405
__le16 default_entry_count; /* default ACL - count of entries */
24112406
struct cifs_posix_ace ace_array[];
2412-
/* followed by
2413-
struct cifs_posix_ace default_ace_arraay[] */
2407+
/* followed by struct cifs_posix_ace default_ace_array[] */
24142408
} __attribute__((packed)); /* level 0x204 */
24152409

24162410
/* types of access control entries already defined in posix_acl.h */
@@ -2429,17 +2423,17 @@ struct cifs_posix_acl { /* access conrol list (ACL) */
24292423
/* end of POSIX ACL definitions */
24302424

24312425
/* POSIX Open Flags */
2432-
#define SMB_O_RDONLY 0x1
2433-
#define SMB_O_WRONLY 0x2
2434-
#define SMB_O_RDWR 0x4
2435-
#define SMB_O_CREAT 0x10
2436-
#define SMB_O_EXCL 0x20
2437-
#define SMB_O_TRUNC 0x40
2438-
#define SMB_O_APPEND 0x80
2439-
#define SMB_O_SYNC 0x100
2440-
#define SMB_O_DIRECTORY 0x200
2441-
#define SMB_O_NOFOLLOW 0x400
2442-
#define SMB_O_DIRECT 0x800
2426+
#define SMB_O_RDONLY 0x1
2427+
#define SMB_O_WRONLY 0x2
2428+
#define SMB_O_RDWR 0x4
2429+
#define SMB_O_CREAT 0x10
2430+
#define SMB_O_EXCL 0x20
2431+
#define SMB_O_TRUNC 0x40
2432+
#define SMB_O_APPEND 0x80
2433+
#define SMB_O_SYNC 0x100
2434+
#define SMB_O_DIRECTORY 0x200
2435+
#define SMB_O_NOFOLLOW 0x400
2436+
#define SMB_O_DIRECT 0x800
24432437

24442438
typedef struct {
24452439
__le32 OpenFlags; /* same as NT CreateX */
@@ -2716,15 +2710,13 @@ typedef struct file_xattr_info {
27162710
__u32 xattr_value_len;
27172711
char xattr_name[];
27182712
/* followed by xattr_value[xattr_value_len], no pad */
2719-
} __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute info
2720-
level 0x205 */
2713+
} __packed FILE_XATTR_INFO; /* extended attribute info level 0x205 */
27212714

27222715
/* flags for lsattr and chflags commands removed arein uapi/linux/fs.h */
27232716

27242717
typedef struct file_chattr_info {
27252718
__le64 mask; /* list of all possible attribute bits */
27262719
__le64 mode; /* list of actual attribute bits on this inode */
2727-
} __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes
2728-
(chattr, chflags) level 0x206 */
2729-
#endif /* POSIX */
2720+
} __packed FILE_CHATTR_INFO; /* ext attributes (chattr, chflags) level 0x206 */
2721+
#endif /* POSIX */
27302722
#endif /* _CIFSPDU_H */

fs/cifs/cifsproto.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
124124
struct kvec * /* resp vec */);
125125
extern int SendReceiveBlockingLock(const unsigned int xid,
126126
struct cifs_tcon *ptcon,
127-
struct smb_hdr *in_buf ,
127+
struct smb_hdr *in_buf,
128128
struct smb_hdr *out_buf,
129129
int *bytes_returned);
130130
void
@@ -604,8 +604,8 @@ int setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw);
604604
int cifs_alloc_hash(const char *name, struct shash_desc **sdesc);
605605
void cifs_free_hash(struct shash_desc **sdesc);
606606

607-
extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page,
608-
unsigned int *len, unsigned int *offset);
607+
void rqst_page_get_length(const struct smb_rqst *rqst, unsigned int page,
608+
unsigned int *len, unsigned int *offset);
609609
struct cifs_chan *
610610
cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server);
611611
int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses);

fs/cifs/file.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,6 +2646,21 @@ wdata_send_pages(struct cifs_writedata *wdata, unsigned int nr_pages,
26462646
return rc;
26472647
}
26482648

2649+
static int
2650+
cifs_writepage_locked(struct page *page, struct writeback_control *wbc);
2651+
2652+
static int cifs_write_one_page(struct page *page, struct writeback_control *wbc,
2653+
void *data)
2654+
{
2655+
struct address_space *mapping = data;
2656+
int ret;
2657+
2658+
ret = cifs_writepage_locked(page, wbc);
2659+
unlock_page(page);
2660+
mapping_set_error(mapping, ret);
2661+
return ret;
2662+
}
2663+
26492664
static int cifs_writepages(struct address_space *mapping,
26502665
struct writeback_control *wbc)
26512666
{
@@ -2662,10 +2677,11 @@ static int cifs_writepages(struct address_space *mapping,
26622677

26632678
/*
26642679
* If wsize is smaller than the page cache size, default to writing
2665-
* one page at a time via cifs_writepage
2680+
* one page at a time.
26662681
*/
26672682
if (cifs_sb->ctx->wsize < PAGE_SIZE)
2668-
return generic_writepages(mapping, wbc);
2683+
return write_cache_pages(mapping, wbc, cifs_write_one_page,
2684+
mapping);
26692685

26702686
xid = get_xid();
26712687
if (wbc->range_cyclic) {
@@ -2852,13 +2868,6 @@ cifs_writepage_locked(struct page *page, struct writeback_control *wbc)
28522868
return rc;
28532869
}
28542870

2855-
static int cifs_writepage(struct page *page, struct writeback_control *wbc)
2856-
{
2857-
int rc = cifs_writepage_locked(page, wbc);
2858-
unlock_page(page);
2859-
return rc;
2860-
}
2861-
28622871
static int cifs_write_end(struct file *file, struct address_space *mapping,
28632872
loff_t pos, unsigned len, unsigned copied,
28642873
struct page *page, void *fsdata)
@@ -5231,7 +5240,6 @@ static bool cifs_dirty_folio(struct address_space *mapping, struct folio *folio)
52315240
const struct address_space_operations cifs_addr_ops = {
52325241
.read_folio = cifs_read_folio,
52335242
.readahead = cifs_readahead,
5234-
.writepage = cifs_writepage,
52355243
.writepages = cifs_writepages,
52365244
.write_begin = cifs_write_begin,
52375245
.write_end = cifs_write_end,
@@ -5240,10 +5248,10 @@ const struct address_space_operations cifs_addr_ops = {
52405248
.direct_IO = cifs_direct_io,
52415249
.invalidate_folio = cifs_invalidate_folio,
52425250
.launder_folio = cifs_launder_folio,
5251+
.migrate_folio = filemap_migrate_folio,
52435252
/*
5244-
* TODO: investigate and if useful we could add an cifs_migratePage
5245-
* helper (under an CONFIG_MIGRATION) in the future, and also
5246-
* investigate and add an is_dirty_writeback helper if needed
5253+
* TODO: investigate and if useful we could add an is_dirty_writeback
5254+
* helper if needed
52475255
*/
52485256
.swap_activate = cifs_swap_activate,
52495257
.swap_deactivate = cifs_swap_deactivate,
@@ -5256,12 +5264,12 @@ const struct address_space_operations cifs_addr_ops = {
52565264
*/
52575265
const struct address_space_operations cifs_addr_ops_smallbuf = {
52585266
.read_folio = cifs_read_folio,
5259-
.writepage = cifs_writepage,
52605267
.writepages = cifs_writepages,
52615268
.write_begin = cifs_write_begin,
52625269
.write_end = cifs_write_end,
52635270
.dirty_folio = cifs_dirty_folio,
52645271
.release_folio = cifs_release_folio,
52655272
.invalidate_folio = cifs_invalidate_folio,
52665273
.launder_folio = cifs_launder_folio,
5274+
.migrate_folio = filemap_migrate_folio,
52675275
};

0 commit comments

Comments
 (0)