Skip to content

Commit 1694472

Browse files
committed
Merge tag '4.20-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes and updates from Steve French: "Three small fixes (one Kerberos related, one for stable, and another fixes an oops in xfstest 377), two helpful debugging improvements, three patches for cifs directio and some minor cleanup" * tag '4.20-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: fix signed/unsigned mismatch on aio_read patch cifs: don't dereference smb_file_target before null check CIFS: Add direct I/O functions to file_operations CIFS: Add support for direct I/O write CIFS: Add support for direct I/O read smb3: missing defines and structs for reparse point handling smb3: allow more detailed protocol info on open files for debugging smb3: on kerberos mount if server doesn't specify auth type use krb5 smb3: add trace point for tree connection cifs: fix spelling mistake, EACCESS -> EACCES cifs: fix return value for cifs_listxattr
2 parents ed61a13 + b98e26d commit 1694472

File tree

12 files changed

+530
-99
lines changed

12 files changed

+530
-99
lines changed

fs/cifs/cifs_debug.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,58 @@ cifs_dump_iface(struct seq_file *m, struct cifs_server_iface *iface)
145145
seq_printf(m, "\t\tIPv6: %pI6\n", &ipv6->sin6_addr);
146146
}
147147

148+
static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
149+
{
150+
struct list_head *stmp, *tmp, *tmp1, *tmp2;
151+
struct TCP_Server_Info *server;
152+
struct cifs_ses *ses;
153+
struct cifs_tcon *tcon;
154+
struct cifsFileInfo *cfile;
155+
156+
seq_puts(m, "# Version:1\n");
157+
seq_puts(m, "# Format:\n");
158+
seq_puts(m, "# <tree id> <persistent fid> <flags> <count> <pid> <uid>");
159+
#ifdef CONFIG_CIFS_DEBUG2
160+
seq_printf(m, " <filename> <mid>\n");
161+
#else
162+
seq_printf(m, " <filename>\n");
163+
#endif /* CIFS_DEBUG2 */
164+
spin_lock(&cifs_tcp_ses_lock);
165+
list_for_each(stmp, &cifs_tcp_ses_list) {
166+
server = list_entry(stmp, struct TCP_Server_Info,
167+
tcp_ses_list);
168+
list_for_each(tmp, &server->smb_ses_list) {
169+
ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
170+
list_for_each(tmp1, &ses->tcon_list) {
171+
tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
172+
spin_lock(&tcon->open_file_lock);
173+
list_for_each(tmp2, &tcon->openFileList) {
174+
cfile = list_entry(tmp2, struct cifsFileInfo,
175+
tlist);
176+
seq_printf(m,
177+
"0x%x 0x%llx 0x%x %d %d %d %s",
178+
tcon->tid,
179+
cfile->fid.persistent_fid,
180+
cfile->f_flags,
181+
cfile->count,
182+
cfile->pid,
183+
from_kuid(&init_user_ns, cfile->uid),
184+
cfile->dentry->d_name.name);
185+
#ifdef CONFIG_CIFS_DEBUG2
186+
seq_printf(m, " 0x%llx\n", cfile->fid.mid);
187+
#else
188+
seq_printf(m, "\n");
189+
#endif /* CIFS_DEBUG2 */
190+
}
191+
spin_unlock(&tcon->open_file_lock);
192+
}
193+
}
194+
}
195+
spin_unlock(&cifs_tcp_ses_lock);
196+
seq_putc(m, '\n');
197+
return 0;
198+
}
199+
148200
static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
149201
{
150202
struct list_head *tmp1, *tmp2, *tmp3;
@@ -565,6 +617,9 @@ cifs_proc_init(void)
565617
proc_create_single("DebugData", 0, proc_fs_cifs,
566618
cifs_debug_data_proc_show);
567619

620+
proc_create_single("open_files", 0400, proc_fs_cifs,
621+
cifs_debug_files_proc_show);
622+
568623
proc_create("Stats", 0644, proc_fs_cifs, &cifs_stats_proc_fops);
569624
proc_create("cifsFYI", 0644, proc_fs_cifs, &cifsFYI_proc_fops);
570625
proc_create("traceSMB", 0644, proc_fs_cifs, &traceSMB_proc_fops);
@@ -601,6 +656,7 @@ cifs_proc_clean(void)
601656
return;
602657

603658
remove_proc_entry("DebugData", proc_fs_cifs);
659+
remove_proc_entry("open_files", proc_fs_cifs);
604660
remove_proc_entry("cifsFYI", proc_fs_cifs);
605661
remove_proc_entry("traceSMB", proc_fs_cifs);
606662
remove_proc_entry("Stats", proc_fs_cifs);

fs/cifs/cifs_spnego.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo)
147147
sprintf(dp, ";sec=krb5");
148148
else if (server->sec_mskerberos)
149149
sprintf(dp, ";sec=mskrb5");
150-
else
151-
goto out;
150+
else {
151+
cifs_dbg(VFS, "unknown or missing server auth type, use krb5\n");
152+
sprintf(dp, ";sec=krb5");
153+
}
152154

153155
dp = description + strlen(description);
154156
sprintf(dp, ";uid=0x%x",

fs/cifs/cifsfs.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,8 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
999999
struct inode *src_inode = file_inode(src_file);
10001000
struct inode *target_inode = file_inode(dst_file);
10011001
struct cifsFileInfo *smb_file_src = src_file->private_data;
1002-
struct cifsFileInfo *smb_file_target = dst_file->private_data;
1003-
struct cifs_tcon *target_tcon = tlink_tcon(smb_file_target->tlink);
1002+
struct cifsFileInfo *smb_file_target;
1003+
struct cifs_tcon *target_tcon;
10041004
unsigned int xid;
10051005
int rc;
10061006

@@ -1017,6 +1017,9 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
10171017
goto out;
10181018
}
10191019

1020+
smb_file_target = dst_file->private_data;
1021+
target_tcon = tlink_tcon(smb_file_target->tlink);
1022+
10201023
/*
10211024
* Note: cifs case is easier than btrfs since server responsible for
10221025
* checks for proper open modes and file type and if it wants
@@ -1180,9 +1183,8 @@ const struct file_operations cifs_file_strict_ops = {
11801183
};
11811184

11821185
const struct file_operations cifs_file_direct_ops = {
1183-
/* BB reevaluate whether they can be done with directio, no cache */
1184-
.read_iter = cifs_user_readv,
1185-
.write_iter = cifs_user_writev,
1186+
.read_iter = cifs_direct_readv,
1187+
.write_iter = cifs_direct_writev,
11861188
.open = cifs_open,
11871189
.release = cifs_close,
11881190
.lock = cifs_lock,
@@ -1236,9 +1238,8 @@ const struct file_operations cifs_file_strict_nobrl_ops = {
12361238
};
12371239

12381240
const struct file_operations cifs_file_direct_nobrl_ops = {
1239-
/* BB reevaluate whether they can be done with directio, no cache */
1240-
.read_iter = cifs_user_readv,
1241-
.write_iter = cifs_user_writev,
1241+
.read_iter = cifs_direct_readv,
1242+
.write_iter = cifs_direct_writev,
12421243
.open = cifs_open,
12431244
.release = cifs_close,
12441245
.fsync = cifs_fsync,

fs/cifs/cifsfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ extern int cifs_open(struct inode *inode, struct file *file);
101101
extern int cifs_close(struct inode *inode, struct file *file);
102102
extern int cifs_closedir(struct inode *inode, struct file *file);
103103
extern ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to);
104+
extern ssize_t cifs_direct_readv(struct kiocb *iocb, struct iov_iter *to);
104105
extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
105106
extern ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from);
107+
extern ssize_t cifs_direct_writev(struct kiocb *iocb, struct iov_iter *from);
106108
extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
107109
extern int cifs_lock(struct file *, int, struct file_lock *);
108110
extern int cifs_fsync(struct file *, loff_t, loff_t, int);

fs/cifs/cifsglob.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,9 @@ struct cifs_fid {
11251125
__u8 create_guid[16];
11261126
struct cifs_pending_open *pending_open;
11271127
unsigned int epoch;
1128+
#ifdef CONFIG_CIFS_DEBUG2
1129+
__u64 mid;
1130+
#endif /* CIFS_DEBUG2 */
11281131
bool purge_cache;
11291132
};
11301133

@@ -1183,6 +1186,11 @@ struct cifs_aio_ctx {
11831186
unsigned int len;
11841187
unsigned int total_len;
11851188
bool should_dirty;
1189+
/*
1190+
* Indicates if this aio_ctx is for direct_io,
1191+
* If yes, iter is a copy of the user passed iov_iter
1192+
*/
1193+
bool direct_io;
11861194
};
11871195

11881196
struct cifs_readdata;

fs/cifs/cifspdu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,9 @@ struct reparse_symlink_data {
15391539
char PathBuffer[0];
15401540
} __attribute__((packed));
15411541

1542+
/* Flag above */
1543+
#define SYMLINK_FLAG_RELATIVE 0x00000001
1544+
15421545
/* For IO_REPARSE_TAG_NFS */
15431546
#define NFS_SPECFILE_LNK 0x00000000014B4E4C
15441547
#define NFS_SPECFILE_CHR 0x0000000000524843

0 commit comments

Comments
 (0)