aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/cifsfs.c')
-rw-r--r--fs/cifs/cifsfs.c199
1 files changed, 105 insertions, 94 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index bd0f2f2353ce..1fd0dc85f53c 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -64,23 +64,27 @@ unsigned int multiuser_mount = 0;
64unsigned int extended_security = CIFSSEC_DEF; 64unsigned int extended_security = CIFSSEC_DEF;
65/* unsigned int ntlmv2_support = 0; */ 65/* unsigned int ntlmv2_support = 0; */
66unsigned int sign_CIFS_PDUs = 1; 66unsigned int sign_CIFS_PDUs = 1;
67extern struct task_struct * oplockThread; /* remove sparse warning */ 67extern struct task_struct *oplockThread; /* remove sparse warning */
68struct task_struct * oplockThread = NULL; 68struct task_struct *oplockThread = NULL;
69/* extern struct task_struct * dnotifyThread; remove sparse warning */ 69/* extern struct task_struct * dnotifyThread; remove sparse warning */
70static struct task_struct * dnotifyThread = NULL; 70static struct task_struct *dnotifyThread = NULL;
71static const struct super_operations cifs_super_ops; 71static const struct super_operations cifs_super_ops;
72unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE; 72unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
73module_param(CIFSMaxBufSize, int, 0); 73module_param(CIFSMaxBufSize, int, 0);
74MODULE_PARM_DESC(CIFSMaxBufSize,"Network buffer size (not including header). Default: 16384 Range: 8192 to 130048"); 74MODULE_PARM_DESC(CIFSMaxBufSize, "Network buffer size (not including header). "
75 "Default: 16384 Range: 8192 to 130048");
75unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL; 76unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
76module_param(cifs_min_rcv, int, 0); 77module_param(cifs_min_rcv, int, 0);
77MODULE_PARM_DESC(cifs_min_rcv,"Network buffers in pool. Default: 4 Range: 1 to 64"); 78MODULE_PARM_DESC(cifs_min_rcv, "Network buffers in pool. Default: 4 Range: "
79 "1 to 64");
78unsigned int cifs_min_small = 30; 80unsigned int cifs_min_small = 30;
79module_param(cifs_min_small, int, 0); 81module_param(cifs_min_small, int, 0);
80MODULE_PARM_DESC(cifs_min_small,"Small network buffers in pool. Default: 30 Range: 2 to 256"); 82MODULE_PARM_DESC(cifs_min_small, "Small network buffers in pool. Default: 30 "
83 "Range: 2 to 256");
81unsigned int cifs_max_pending = CIFS_MAX_REQ; 84unsigned int cifs_max_pending = CIFS_MAX_REQ;
82module_param(cifs_max_pending, int, 0); 85module_param(cifs_max_pending, int, 0);
83MODULE_PARM_DESC(cifs_max_pending,"Simultaneous requests to server. Default: 50 Range: 2 to 256"); 86MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server. "
87 "Default: 50 Range: 2 to 256");
84 88
85extern mempool_t *cifs_sm_req_poolp; 89extern mempool_t *cifs_sm_req_poolp;
86extern mempool_t *cifs_req_poolp; 90extern mempool_t *cifs_req_poolp;
@@ -95,10 +99,10 @@ cifs_read_super(struct super_block *sb, void *data,
95 struct inode *inode; 99 struct inode *inode;
96 struct cifs_sb_info *cifs_sb; 100 struct cifs_sb_info *cifs_sb;
97 int rc = 0; 101 int rc = 0;
98 102
99 /* BB should we make this contingent on mount parm? */ 103 /* BB should we make this contingent on mount parm? */
100 sb->s_flags |= MS_NODIRATIME | MS_NOATIME; 104 sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
101 sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL); 105 sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
102 cifs_sb = CIFS_SB(sb); 106 cifs_sb = CIFS_SB(sb);
103 if (cifs_sb == NULL) 107 if (cifs_sb == NULL)
104 return -ENOMEM; 108 return -ENOMEM;
@@ -114,12 +118,9 @@ cifs_read_super(struct super_block *sb, void *data,
114 118
115 sb->s_magic = CIFS_MAGIC_NUMBER; 119 sb->s_magic = CIFS_MAGIC_NUMBER;
116 sb->s_op = &cifs_super_ops; 120 sb->s_op = &cifs_super_ops;
117#ifdef CONFIG_CIFS_EXPERIMENTAL
118 if (experimEnabled != 0)
119 sb->s_export_op = &cifs_export_ops;
120#endif /* EXPERIMENTAL */
121/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512) 121/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
122 sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */ 122 sb->s_blocksize =
123 cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
123#ifdef CONFIG_CIFS_QUOTA 124#ifdef CONFIG_CIFS_QUOTA
124 sb->s_qcop = &cifs_quotactl_ops; 125 sb->s_qcop = &cifs_quotactl_ops;
125#endif 126#endif
@@ -139,6 +140,13 @@ cifs_read_super(struct super_block *sb, void *data,
139 goto out_no_root; 140 goto out_no_root;
140 } 141 }
141 142
143#ifdef CONFIG_CIFS_EXPERIMENTAL
144 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
145 cFYI(1, ("export ops supported"));
146 sb->s_export_op = &cifs_export_ops;
147 }
148#endif /* EXPERIMENTAL */
149
142 return 0; 150 return 0;
143 151
144out_no_root: 152out_no_root:
@@ -149,7 +157,7 @@ out_no_root:
149out_mount_failed: 157out_mount_failed:
150 if (cifs_sb) { 158 if (cifs_sb) {
151 if (cifs_sb->local_nls) 159 if (cifs_sb->local_nls)
152 unload_nls(cifs_sb->local_nls); 160 unload_nls(cifs_sb->local_nls);
153 kfree(cifs_sb); 161 kfree(cifs_sb);
154 } 162 }
155 return rc; 163 return rc;
@@ -164,10 +172,10 @@ cifs_put_super(struct super_block *sb)
164 cFYI(1, ("In cifs_put_super")); 172 cFYI(1, ("In cifs_put_super"));
165 cifs_sb = CIFS_SB(sb); 173 cifs_sb = CIFS_SB(sb);
166 if (cifs_sb == NULL) { 174 if (cifs_sb == NULL) {
167 cFYI(1,("Empty cifs superblock info passed to unmount")); 175 cFYI(1, ("Empty cifs superblock info passed to unmount"));
168 return; 176 return;
169 } 177 }
170 rc = cifs_umount(sb, cifs_sb); 178 rc = cifs_umount(sb, cifs_sb);
171 if (rc) { 179 if (rc) {
172 cERROR(1, ("cifs_umount failed with return code %d", rc)); 180 cERROR(1, ("cifs_umount failed with return code %d", rc));
173 } 181 }
@@ -180,7 +188,7 @@ static int
180cifs_statfs(struct dentry *dentry, struct kstatfs *buf) 188cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
181{ 189{
182 struct super_block *sb = dentry->d_sb; 190 struct super_block *sb = dentry->d_sb;
183 int xid; 191 int xid;
184 int rc = -EOPNOTSUPP; 192 int rc = -EOPNOTSUPP;
185 struct cifs_sb_info *cifs_sb; 193 struct cifs_sb_info *cifs_sb;
186 struct cifsTconInfo *pTcon; 194 struct cifsTconInfo *pTcon;
@@ -193,7 +201,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
193 buf->f_type = CIFS_MAGIC_NUMBER; 201 buf->f_type = CIFS_MAGIC_NUMBER;
194 202
195 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */ 203 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */
196 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would 204 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would
197 presumably be total path, but note 205 presumably be total path, but note
198 that some servers (includinng Samba 3) 206 that some servers (includinng Samba 3)
199 have a shorter maximum path */ 207 have a shorter maximum path */
@@ -217,8 +225,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
217 bypassed it because we detected that this was an older LANMAN sess */ 225 bypassed it because we detected that this was an older LANMAN sess */
218 if (rc) 226 if (rc)
219 rc = SMBOldQFSInfo(xid, pTcon, buf); 227 rc = SMBOldQFSInfo(xid, pTcon, buf);
220 /* 228 /* int f_type;
221 int f_type;
222 __fsid_t f_fsid; 229 __fsid_t f_fsid;
223 int f_namelen; */ 230 int f_namelen; */
224 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */ 231 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */
@@ -227,7 +234,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
227 longer available? */ 234 longer available? */
228} 235}
229 236
230static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd) 237static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd)
231{ 238{
232 struct cifs_sb_info *cifs_sb; 239 struct cifs_sb_info *cifs_sb;
233 240
@@ -235,10 +242,10 @@ static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
235 242
236 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) { 243 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
237 return 0; 244 return 0;
238 } else /* file mode might have been restricted at mount time 245 } else /* file mode might have been restricted at mount time
239 on the client (above and beyond ACL on servers) for 246 on the client (above and beyond ACL on servers) for
240 servers which do not support setting and viewing mode bits, 247 servers which do not support setting and viewing mode bits,
241 so allowing client to check permissions is useful */ 248 so allowing client to check permissions is useful */
242 return generic_permission(inode, mask, NULL); 249 return generic_permission(inode, mask, NULL);
243} 250}
244 251
@@ -267,7 +274,7 @@ cifs_alloc_inode(struct super_block *sb)
267 cifs_inode->clientCanCacheRead = FALSE; 274 cifs_inode->clientCanCacheRead = FALSE;
268 cifs_inode->clientCanCacheAll = FALSE; 275 cifs_inode->clientCanCacheAll = FALSE;
269 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ 276 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
270 277
271 /* Can not set i_flags here - they get immediately overwritten 278 /* Can not set i_flags here - they get immediately overwritten
272 to zero by the VFS */ 279 to zero by the VFS */
273/* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME;*/ 280/* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME;*/
@@ -309,26 +316,26 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
309 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 316 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
310 seq_printf(s, ",posixpaths"); 317 seq_printf(s, ",posixpaths");
311 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) || 318 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) ||
312 !(cifs_sb->tcon->ses->capabilities & CAP_UNIX)) 319 !(cifs_sb->tcon->unix_ext))
313 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid); 320 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
314 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) || 321 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
315 !(cifs_sb->tcon->ses->capabilities & CAP_UNIX)) 322 !(cifs_sb->tcon->unix_ext))
316 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid); 323 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
317 seq_printf(s, ",rsize=%d",cifs_sb->rsize); 324 seq_printf(s, ",rsize=%d", cifs_sb->rsize);
318 seq_printf(s, ",wsize=%d",cifs_sb->wsize); 325 seq_printf(s, ",wsize=%d", cifs_sb->wsize);
319 } 326 }
320 return 0; 327 return 0;
321} 328}
322 329
323#ifdef CONFIG_CIFS_QUOTA 330#ifdef CONFIG_CIFS_QUOTA
324int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid, 331int cifs_xquota_set(struct super_block *sb, int quota_type, qid_t qid,
325 struct fs_disk_quota * pdquota) 332 struct fs_disk_quota *pdquota)
326{ 333{
327 int xid; 334 int xid;
328 int rc = 0; 335 int rc = 0;
329 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 336 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
330 struct cifsTconInfo *pTcon; 337 struct cifsTconInfo *pTcon;
331 338
332 if (cifs_sb) 339 if (cifs_sb)
333 pTcon = cifs_sb->tcon; 340 pTcon = cifs_sb->tcon;
334 else 341 else
@@ -337,7 +344,7 @@ int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid,
337 344
338 xid = GetXid(); 345 xid = GetXid();
339 if (pTcon) { 346 if (pTcon) {
340 cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); 347 cFYI(1, ("set type: 0x%x id: %d", quota_type, qid));
341 } else { 348 } else {
342 return -EIO; 349 return -EIO;
343 } 350 }
@@ -346,8 +353,8 @@ int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid,
346 return rc; 353 return rc;
347} 354}
348 355
349int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid, 356int cifs_xquota_get(struct super_block *sb, int quota_type, qid_t qid,
350 struct fs_disk_quota * pdquota) 357 struct fs_disk_quota *pdquota)
351{ 358{
352 int xid; 359 int xid;
353 int rc = 0; 360 int rc = 0;
@@ -361,7 +368,7 @@ int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid,
361 368
362 xid = GetXid(); 369 xid = GetXid();
363 if (pTcon) { 370 if (pTcon) {
364 cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); 371 cFYI(1, ("set type: 0x%x id: %d", quota_type, qid));
365 } else { 372 } else {
366 rc = -EIO; 373 rc = -EIO;
367 } 374 }
@@ -370,9 +377,9 @@ int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid,
370 return rc; 377 return rc;
371} 378}
372 379
373int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation) 380int cifs_xstate_set(struct super_block *sb, unsigned int flags, int operation)
374{ 381{
375 int xid; 382 int xid;
376 int rc = 0; 383 int rc = 0;
377 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 384 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
378 struct cifsTconInfo *pTcon; 385 struct cifsTconInfo *pTcon;
@@ -384,7 +391,7 @@ int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation)
384 391
385 xid = GetXid(); 392 xid = GetXid();
386 if (pTcon) { 393 if (pTcon) {
387 cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation)); 394 cFYI(1, ("flags: 0x%x operation: 0x%x", flags, operation));
388 } else { 395 } else {
389 rc = -EIO; 396 rc = -EIO;
390 } 397 }
@@ -393,7 +400,7 @@ int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation)
393 return rc; 400 return rc;
394} 401}
395 402
396int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats) 403int cifs_xstate_get(struct super_block *sb, struct fs_quota_stat *qstats)
397{ 404{
398 int xid; 405 int xid;
399 int rc = 0; 406 int rc = 0;
@@ -407,7 +414,7 @@ int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats)
407 } 414 }
408 xid = GetXid(); 415 xid = GetXid();
409 if (pTcon) { 416 if (pTcon) {
410 cFYI(1,("pqstats %p",qstats)); 417 cFYI(1, ("pqstats %p", qstats));
411 } else { 418 } else {
412 rc = -EIO; 419 rc = -EIO;
413 } 420 }
@@ -424,10 +431,10 @@ static struct quotactl_ops cifs_quotactl_ops = {
424}; 431};
425#endif 432#endif
426 433
427static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags) 434static void cifs_umount_begin(struct vfsmount *vfsmnt, int flags)
428{ 435{
429 struct cifs_sb_info *cifs_sb; 436 struct cifs_sb_info *cifs_sb;
430 struct cifsTconInfo * tcon; 437 struct cifsTconInfo *tcon;
431 438
432 if (!(flags & MNT_FORCE)) 439 if (!(flags & MNT_FORCE))
433 return; 440 return;
@@ -445,9 +452,8 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags)
445 452
446 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ 453 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
447 /* cancel_notify_requests(tcon); */ 454 /* cancel_notify_requests(tcon); */
448 if (tcon->ses && tcon->ses->server) 455 if (tcon->ses && tcon->ses->server) {
449 { 456 cFYI(1, ("wake up tasks now - umount begin not complete"));
450 cFYI(1,("wake up tasks now - umount begin not complete"));
451 wake_up_all(&tcon->ses->server->request_q); 457 wake_up_all(&tcon->ses->server->request_q);
452 wake_up_all(&tcon->ses->server->response_q); 458 wake_up_all(&tcon->ses->server->response_q);
453 msleep(1); /* yield */ 459 msleep(1); /* yield */
@@ -480,10 +486,11 @@ static const struct super_operations cifs_super_ops = {
480 .statfs = cifs_statfs, 486 .statfs = cifs_statfs,
481 .alloc_inode = cifs_alloc_inode, 487 .alloc_inode = cifs_alloc_inode,
482 .destroy_inode = cifs_destroy_inode, 488 .destroy_inode = cifs_destroy_inode,
483/* .drop_inode = generic_delete_inode, 489/* .drop_inode = generic_delete_inode,
484 .delete_inode = cifs_delete_inode, *//* Do not need the above two functions 490 .delete_inode = cifs_delete_inode, */ /* Do not need above two
485 unless later we add lazy close of inodes or unless the kernel forgets to call 491 functions unless later we add lazy close of inodes or unless the
486 us with the same number of releases (closes) as opens */ 492 kernel forgets to call us with the same number of releases (closes)
493 as opens */
487 .show_options = cifs_show_options, 494 .show_options = cifs_show_options,
488 .umount_begin = cifs_umount_begin, 495 .umount_begin = cifs_umount_begin,
489 .remount_fs = cifs_remount, 496 .remount_fs = cifs_remount,
@@ -586,11 +593,11 @@ const struct inode_operations cifs_file_inode_ops = {
586 .getxattr = cifs_getxattr, 593 .getxattr = cifs_getxattr,
587 .listxattr = cifs_listxattr, 594 .listxattr = cifs_listxattr,
588 .removexattr = cifs_removexattr, 595 .removexattr = cifs_removexattr,
589#endif 596#endif
590}; 597};
591 598
592const struct inode_operations cifs_symlink_inode_ops = { 599const struct inode_operations cifs_symlink_inode_ops = {
593 .readlink = generic_readlink, 600 .readlink = generic_readlink,
594 .follow_link = cifs_follow_link, 601 .follow_link = cifs_follow_link,
595 .put_link = cifs_put_link, 602 .put_link = cifs_put_link,
596 .permission = cifs_permission, 603 .permission = cifs_permission,
@@ -602,7 +609,7 @@ const struct inode_operations cifs_symlink_inode_ops = {
602 .getxattr = cifs_getxattr, 609 .getxattr = cifs_getxattr,
603 .listxattr = cifs_listxattr, 610 .listxattr = cifs_listxattr,
604 .removexattr = cifs_removexattr, 611 .removexattr = cifs_removexattr,
605#endif 612#endif
606}; 613};
607 614
608const struct file_operations cifs_file_ops = { 615const struct file_operations cifs_file_ops = {
@@ -628,7 +635,7 @@ const struct file_operations cifs_file_ops = {
628}; 635};
629 636
630const struct file_operations cifs_file_direct_ops = { 637const struct file_operations cifs_file_direct_ops = {
631 /* no mmap, no aio, no readv - 638 /* no mmap, no aio, no readv -
632 BB reevaluate whether they can be done with directio, no cache */ 639 BB reevaluate whether they can be done with directio, no cache */
633 .read = cifs_user_read, 640 .read = cifs_user_read,
634 .write = cifs_user_write, 641 .write = cifs_user_write,
@@ -668,7 +675,7 @@ const struct file_operations cifs_file_nobrl_ops = {
668}; 675};
669 676
670const struct file_operations cifs_file_direct_nobrl_ops = { 677const struct file_operations cifs_file_direct_nobrl_ops = {
671 /* no mmap, no aio, no readv - 678 /* no mmap, no aio, no readv -
672 BB reevaluate whether they can be done with directio, no cache */ 679 BB reevaluate whether they can be done with directio, no cache */
673 .read = cifs_user_read, 680 .read = cifs_user_read,
674 .write = cifs_user_write, 681 .write = cifs_user_write,
@@ -693,11 +700,11 @@ const struct file_operations cifs_dir_ops = {
693#ifdef CONFIG_CIFS_EXPERIMENTAL 700#ifdef CONFIG_CIFS_EXPERIMENTAL
694 .dir_notify = cifs_dir_notify, 701 .dir_notify = cifs_dir_notify,
695#endif /* CONFIG_CIFS_EXPERIMENTAL */ 702#endif /* CONFIG_CIFS_EXPERIMENTAL */
696 .ioctl = cifs_ioctl, 703 .ioctl = cifs_ioctl,
697}; 704};
698 705
699static void 706static void
700cifs_init_once(void *inode, struct kmem_cache * cachep, unsigned long flags) 707cifs_init_once(void *inode, struct kmem_cache *cachep, unsigned long flags)
701{ 708{
702 struct cifsInodeInfo *cifsi = inode; 709 struct cifsInodeInfo *cifsi = inode;
703 710
@@ -749,7 +756,7 @@ cifs_init_request_bufs(void)
749 cifs_min_rcv = 1; 756 cifs_min_rcv = 1;
750 else if (cifs_min_rcv > 64) { 757 else if (cifs_min_rcv > 64) {
751 cifs_min_rcv = 64; 758 cifs_min_rcv = 64;
752 cERROR(1,("cifs_min_rcv set to maximum (64)")); 759 cERROR(1, ("cifs_min_rcv set to maximum (64)"));
753 } 760 }
754 761
755 cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv, 762 cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
@@ -762,25 +769,25 @@ cifs_init_request_bufs(void)
762 /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and 769 /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and
763 almost all handle based requests (but not write response, nor is it 770 almost all handle based requests (but not write response, nor is it
764 sufficient for path based requests). A smaller size would have 771 sufficient for path based requests). A smaller size would have
765 been more efficient (compacting multiple slab items on one 4k page) 772 been more efficient (compacting multiple slab items on one 4k page)
766 for the case in which debug was on, but this larger size allows 773 for the case in which debug was on, but this larger size allows
767 more SMBs to use small buffer alloc and is still much more 774 more SMBs to use small buffer alloc and is still much more
768 efficient to alloc 1 per page off the slab compared to 17K (5page) 775 efficient to alloc 1 per page off the slab compared to 17K (5page)
769 alloc of large cifs buffers even when page debugging is on */ 776 alloc of large cifs buffers even when page debugging is on */
770 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq", 777 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
771 MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN, 778 MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
772 NULL, NULL); 779 NULL, NULL);
773 if (cifs_sm_req_cachep == NULL) { 780 if (cifs_sm_req_cachep == NULL) {
774 mempool_destroy(cifs_req_poolp); 781 mempool_destroy(cifs_req_poolp);
775 kmem_cache_destroy(cifs_req_cachep); 782 kmem_cache_destroy(cifs_req_cachep);
776 return -ENOMEM; 783 return -ENOMEM;
777 } 784 }
778 785
779 if (cifs_min_small < 2) 786 if (cifs_min_small < 2)
780 cifs_min_small = 2; 787 cifs_min_small = 2;
781 else if (cifs_min_small > 256) { 788 else if (cifs_min_small > 256) {
782 cifs_min_small = 256; 789 cifs_min_small = 256;
783 cFYI(1,("cifs_min_small set to maximum (256)")); 790 cFYI(1, ("cifs_min_small set to maximum (256)"));
784 } 791 }
785 792
786 cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small, 793 cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
@@ -841,42 +848,43 @@ cifs_destroy_mids(void)
841 kmem_cache_destroy(cifs_oplock_cachep); 848 kmem_cache_destroy(cifs_oplock_cachep);
842} 849}
843 850
844static int cifs_oplock_thread(void * dummyarg) 851static int cifs_oplock_thread(void *dummyarg)
845{ 852{
846 struct oplock_q_entry * oplock_item; 853 struct oplock_q_entry *oplock_item;
847 struct cifsTconInfo *pTcon; 854 struct cifsTconInfo *pTcon;
848 struct inode * inode; 855 struct inode *inode;
849 __u16 netfid; 856 __u16 netfid;
850 int rc; 857 int rc;
851 858
852 set_freezable(); 859 set_freezable();
853 do { 860 do {
854 if (try_to_freeze()) 861 if (try_to_freeze())
855 continue; 862 continue;
856 863
857 spin_lock(&GlobalMid_Lock); 864 spin_lock(&GlobalMid_Lock);
858 if (list_empty(&GlobalOplock_Q)) { 865 if (list_empty(&GlobalOplock_Q)) {
859 spin_unlock(&GlobalMid_Lock); 866 spin_unlock(&GlobalMid_Lock);
860 set_current_state(TASK_INTERRUPTIBLE); 867 set_current_state(TASK_INTERRUPTIBLE);
861 schedule_timeout(39*HZ); 868 schedule_timeout(39*HZ);
862 } else { 869 } else {
863 oplock_item = list_entry(GlobalOplock_Q.next, 870 oplock_item = list_entry(GlobalOplock_Q.next,
864 struct oplock_q_entry, qhead); 871 struct oplock_q_entry, qhead);
865 if (oplock_item) { 872 if (oplock_item) {
866 cFYI(1,("found oplock item to write out")); 873 cFYI(1, ("found oplock item to write out"));
867 pTcon = oplock_item->tcon; 874 pTcon = oplock_item->tcon;
868 inode = oplock_item->pinode; 875 inode = oplock_item->pinode;
869 netfid = oplock_item->netfid; 876 netfid = oplock_item->netfid;
870 spin_unlock(&GlobalMid_Lock); 877 spin_unlock(&GlobalMid_Lock);
871 DeleteOplockQEntry(oplock_item); 878 DeleteOplockQEntry(oplock_item);
872 /* can not grab inode sem here since it would 879 /* can not grab inode sem here since it would
873 deadlock when oplock received on delete 880 deadlock when oplock received on delete
874 since vfs_unlink holds the i_mutex across 881 since vfs_unlink holds the i_mutex across
875 the call */ 882 the call */
876 /* mutex_lock(&inode->i_mutex);*/ 883 /* mutex_lock(&inode->i_mutex);*/
877 if (S_ISREG(inode->i_mode)) { 884 if (S_ISREG(inode->i_mode)) {
878 rc = filemap_fdatawrite(inode->i_mapping); 885 rc = filemap_fdatawrite(inode->i_mapping);
879 if (CIFS_I(inode)->clientCanCacheRead == 0) { 886 if (CIFS_I(inode)->clientCanCacheRead
887 == 0) {
880 filemap_fdatawait(inode->i_mapping); 888 filemap_fdatawait(inode->i_mapping);
881 invalidate_remote_inode(inode); 889 invalidate_remote_inode(inode);
882 } 890 }
@@ -885,20 +893,22 @@ static int cifs_oplock_thread(void * dummyarg)
885 /* mutex_unlock(&inode->i_mutex);*/ 893 /* mutex_unlock(&inode->i_mutex);*/
886 if (rc) 894 if (rc)
887 CIFS_I(inode)->write_behind_rc = rc; 895 CIFS_I(inode)->write_behind_rc = rc;
888 cFYI(1,("Oplock flush inode %p rc %d",inode,rc)); 896 cFYI(1, ("Oplock flush inode %p rc %d",
889 897 inode, rc));
890 /* releasing a stale oplock after recent reconnection 898
891 of smb session using a now incorrect file 899 /* releasing stale oplock after recent reconnect
892 handle is not a data integrity issue but do 900 of smb session using a now incorrect file
893 not bother sending an oplock release if session 901 handle is not a data integrity issue but do
894 to server still is disconnected since oplock 902 not bother sending an oplock release if session
903 to server still is disconnected since oplock
895 already released by the server in that case */ 904 already released by the server in that case */
896 if (pTcon->tidStatus != CifsNeedReconnect) { 905 if (pTcon->tidStatus != CifsNeedReconnect) {
897 rc = CIFSSMBLock(0, pTcon, netfid, 906 rc = CIFSSMBLock(0, pTcon, netfid,
898 0 /* len */ , 0 /* offset */, 0, 907 0 /* len */ , 0 /* offset */, 0,
899 0, LOCKING_ANDX_OPLOCK_RELEASE, 908 0, LOCKING_ANDX_OPLOCK_RELEASE,
900 0 /* wait flag */); 909 0 /* wait flag */);
901 cFYI(1,("Oplock release rc = %d ",rc)); 910 cFYI(1,
911 ("Oplock release rc = %d ", rc));
902 } 912 }
903 } else 913 } else
904 spin_unlock(&GlobalMid_Lock); 914 spin_unlock(&GlobalMid_Lock);
@@ -910,7 +920,7 @@ static int cifs_oplock_thread(void * dummyarg)
910 return 0; 920 return 0;
911} 921}
912 922
913static int cifs_dnotify_thread(void * dummyarg) 923static int cifs_dnotify_thread(void *dummyarg)
914{ 924{
915 struct list_head *tmp; 925 struct list_head *tmp;
916 struct cifsSesInfo *ses; 926 struct cifsSesInfo *ses;
@@ -925,9 +935,9 @@ static int cifs_dnotify_thread(void * dummyarg)
925 to be woken up and wakeq so the 935 to be woken up and wakeq so the
926 thread can wake up and error out */ 936 thread can wake up and error out */
927 list_for_each(tmp, &GlobalSMBSessionList) { 937 list_for_each(tmp, &GlobalSMBSessionList) {
928 ses = list_entry(tmp, struct cifsSesInfo, 938 ses = list_entry(tmp, struct cifsSesInfo,
929 cifsSessionList); 939 cifsSessionList);
930 if (ses && ses->server && 940 if (ses && ses->server &&
931 atomic_read(&ses->server->inFlight)) 941 atomic_read(&ses->server->inFlight))
932 wake_up_all(&ses->server->response_q); 942 wake_up_all(&ses->server->response_q);
933 } 943 }
@@ -951,13 +961,13 @@ init_cifs(void)
951#ifdef CONFIG_CIFS_EXPERIMENTAL 961#ifdef CONFIG_CIFS_EXPERIMENTAL
952 INIT_LIST_HEAD(&GlobalDnotifyReqList); 962 INIT_LIST_HEAD(&GlobalDnotifyReqList);
953 INIT_LIST_HEAD(&GlobalDnotifyRsp_Q); 963 INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
954#endif 964#endif
955/* 965/*
956 * Initialize Global counters 966 * Initialize Global counters
957 */ 967 */
958 atomic_set(&sesInfoAllocCount, 0); 968 atomic_set(&sesInfoAllocCount, 0);
959 atomic_set(&tconInfoAllocCount, 0); 969 atomic_set(&tconInfoAllocCount, 0);
960 atomic_set(&tcpSesAllocCount,0); 970 atomic_set(&tcpSesAllocCount, 0);
961 atomic_set(&tcpSesReconnectCount, 0); 971 atomic_set(&tcpSesReconnectCount, 0);
962 atomic_set(&tconInfoReconnectCount, 0); 972 atomic_set(&tconInfoReconnectCount, 0);
963 973
@@ -978,10 +988,10 @@ init_cifs(void)
978 988
979 if (cifs_max_pending < 2) { 989 if (cifs_max_pending < 2) {
980 cifs_max_pending = 2; 990 cifs_max_pending = 2;
981 cFYI(1,("cifs_max_pending set to min of 2")); 991 cFYI(1, ("cifs_max_pending set to min of 2"));
982 } else if (cifs_max_pending > 256) { 992 } else if (cifs_max_pending > 256) {
983 cifs_max_pending = 256; 993 cifs_max_pending = 256;
984 cFYI(1,("cifs_max_pending set to max of 256")); 994 cFYI(1, ("cifs_max_pending set to max of 256"));
985 } 995 }
986 996
987 rc = cifs_init_inodecache(); 997 rc = cifs_init_inodecache();
@@ -1003,14 +1013,14 @@ init_cifs(void)
1003 oplockThread = kthread_run(cifs_oplock_thread, NULL, "cifsoplockd"); 1013 oplockThread = kthread_run(cifs_oplock_thread, NULL, "cifsoplockd");
1004 if (IS_ERR(oplockThread)) { 1014 if (IS_ERR(oplockThread)) {
1005 rc = PTR_ERR(oplockThread); 1015 rc = PTR_ERR(oplockThread);
1006 cERROR(1,("error %d create oplock thread", rc)); 1016 cERROR(1, ("error %d create oplock thread", rc));
1007 goto out_unregister_filesystem; 1017 goto out_unregister_filesystem;
1008 } 1018 }
1009 1019
1010 dnotifyThread = kthread_run(cifs_dnotify_thread, NULL, "cifsdnotifyd"); 1020 dnotifyThread = kthread_run(cifs_dnotify_thread, NULL, "cifsdnotifyd");
1011 if (IS_ERR(dnotifyThread)) { 1021 if (IS_ERR(dnotifyThread)) {
1012 rc = PTR_ERR(dnotifyThread); 1022 rc = PTR_ERR(dnotifyThread);
1013 cERROR(1,("error %d create dnotify thread", rc)); 1023 cERROR(1, ("error %d create dnotify thread", rc));
1014 goto out_stop_oplock_thread; 1024 goto out_stop_oplock_thread;
1015 } 1025 }
1016 1026
@@ -1036,7 +1046,7 @@ init_cifs(void)
1036static void __exit 1046static void __exit
1037exit_cifs(void) 1047exit_cifs(void)
1038{ 1048{
1039 cFYI(0, ("In unregister ie exit_cifs")); 1049 cFYI(0, ("exit_cifs"));
1040#ifdef CONFIG_PROC_FS 1050#ifdef CONFIG_PROC_FS
1041 cifs_proc_clean(); 1051 cifs_proc_clean();
1042#endif 1052#endif
@@ -1049,9 +1059,10 @@ exit_cifs(void)
1049} 1059}
1050 1060
1051MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>"); 1061MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
1052MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */ 1062MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
1053MODULE_DESCRIPTION 1063MODULE_DESCRIPTION
1054 ("VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows"); 1064 ("VFS to access servers complying with the SNIA CIFS Specification "
1065 "e.g. Samba and Windows");
1055MODULE_VERSION(CIFS_VERSION); 1066MODULE_VERSION(CIFS_VERSION);
1056module_init(init_cifs) 1067module_init(init_cifs)
1057module_exit(exit_cifs) 1068module_exit(exit_cifs)