aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c88
1 files changed, 53 insertions, 35 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 12cf72dd0c42..7f540df52527 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2546,7 +2546,7 @@ ip_connect(struct TCP_Server_Info *server)
2546} 2546}
2547 2547
2548void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon, 2548void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon,
2549 struct super_block *sb, struct smb_vol *vol_info) 2549 struct cifs_sb_info *cifs_sb, struct smb_vol *vol_info)
2550{ 2550{
2551 /* if we are reconnecting then should we check to see if 2551 /* if we are reconnecting then should we check to see if
2552 * any requested capabilities changed locally e.g. via 2552 * any requested capabilities changed locally e.g. via
@@ -2600,22 +2600,23 @@ void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon,
2600 cap &= ~CIFS_UNIX_POSIX_ACL_CAP; 2600 cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
2601 else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { 2601 else if (CIFS_UNIX_POSIX_ACL_CAP & cap) {
2602 cFYI(1, "negotiated posix acl support"); 2602 cFYI(1, "negotiated posix acl support");
2603 if (sb) 2603 if (cifs_sb)
2604 sb->s_flags |= MS_POSIXACL; 2604 cifs_sb->mnt_cifs_flags |=
2605 CIFS_MOUNT_POSIXACL;
2605 } 2606 }
2606 2607
2607 if (vol_info && vol_info->posix_paths == 0) 2608 if (vol_info && vol_info->posix_paths == 0)
2608 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; 2609 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
2609 else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { 2610 else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
2610 cFYI(1, "negotiate posix pathnames"); 2611 cFYI(1, "negotiate posix pathnames");
2611 if (sb) 2612 if (cifs_sb)
2612 CIFS_SB(sb)->mnt_cifs_flags |= 2613 cifs_sb->mnt_cifs_flags |=
2613 CIFS_MOUNT_POSIX_PATHS; 2614 CIFS_MOUNT_POSIX_PATHS;
2614 } 2615 }
2615 2616
2616 if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) { 2617 if (cifs_sb && (cifs_sb->rsize > 127 * 1024)) {
2617 if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { 2618 if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) {
2618 CIFS_SB(sb)->rsize = 127 * 1024; 2619 cifs_sb->rsize = 127 * 1024;
2619 cFYI(DBG2, "larger reads not supported by srv"); 2620 cFYI(DBG2, "larger reads not supported by srv");
2620 } 2621 }
2621 } 2622 }
@@ -2662,6 +2663,9 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
2662{ 2663{
2663 INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks); 2664 INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks);
2664 2665
2666 spin_lock_init(&cifs_sb->tlink_tree_lock);
2667 cifs_sb->tlink_tree = RB_ROOT;
2668
2665 if (pvolume_info->rsize > CIFSMaxBufSize) { 2669 if (pvolume_info->rsize > CIFSMaxBufSize) {
2666 cERROR(1, "rsize %d too large, using MaxBufSize", 2670 cERROR(1, "rsize %d too large, using MaxBufSize",
2667 pvolume_info->rsize); 2671 pvolume_info->rsize);
@@ -2750,21 +2754,21 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
2750 2754
2751/* 2755/*
2752 * When the server supports very large writes via POSIX extensions, we can 2756 * When the server supports very large writes via POSIX extensions, we can
2753 * allow up to 2^24 - PAGE_CACHE_SIZE. 2757 * allow up to 2^24-1, minus the size of a WRITE_AND_X header, not including
2758 * the RFC1001 length.
2754 * 2759 *
2755 * Note that this might make for "interesting" allocation problems during 2760 * Note that this might make for "interesting" allocation problems during
2756 * writeback however (as we have to allocate an array of pointers for the 2761 * writeback however as we have to allocate an array of pointers for the
2757 * pages). A 16M write means ~32kb page array with PAGE_CACHE_SIZE == 4096. 2762 * pages. A 16M write means ~32kb page array with PAGE_CACHE_SIZE == 4096.
2758 */ 2763 */
2759#define CIFS_MAX_WSIZE ((1<<24) - PAGE_CACHE_SIZE) 2764#define CIFS_MAX_WSIZE ((1<<24) - 1 - sizeof(WRITE_REQ) + 4)
2760 2765
2761/* 2766/*
2762 * When the server doesn't allow large posix writes, default to a wsize of 2767 * When the server doesn't allow large posix writes, only allow a wsize of
2763 * 128k - PAGE_CACHE_SIZE -- one page less than the largest frame size 2768 * 128k minus the size of the WRITE_AND_X header. That allows for a write up
2764 * described in RFC1001. This allows space for the header without going over 2769 * to the maximum size described by RFC1002.
2765 * that by default.
2766 */ 2770 */
2767#define CIFS_MAX_RFC1001_WSIZE (128 * 1024 - PAGE_CACHE_SIZE) 2771#define CIFS_MAX_RFC1002_WSIZE (128 * 1024 - sizeof(WRITE_REQ) + 4)
2768 2772
2769/* 2773/*
2770 * The default wsize is 1M. find_get_pages seems to return a maximum of 256 2774 * The default wsize is 1M. find_get_pages seems to return a maximum of 256
@@ -2783,11 +2787,18 @@ cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info)
2783 2787
2784 /* can server support 24-bit write sizes? (via UNIX extensions) */ 2788 /* can server support 24-bit write sizes? (via UNIX extensions) */
2785 if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) 2789 if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP))
2786 wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1001_WSIZE); 2790 wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1002_WSIZE);
2787 2791
2788 /* no CAP_LARGE_WRITE_X? Limit it to 16 bits */ 2792 /*
2789 if (!(server->capabilities & CAP_LARGE_WRITE_X)) 2793 * no CAP_LARGE_WRITE_X or is signing enabled without CAP_UNIX set?
2790 wsize = min_t(unsigned int, wsize, USHRT_MAX); 2794 * Limit it to max buffer offered by the server, minus the size of the
2795 * WRITEX header, not including the 4 byte RFC1001 length.
2796 */
2797 if (!(server->capabilities & CAP_LARGE_WRITE_X) ||
2798 (!(server->capabilities & CAP_UNIX) &&
2799 (server->sec_mode & (SECMODE_SIGN_ENABLED|SECMODE_SIGN_REQUIRED))))
2800 wsize = min_t(unsigned int, wsize,
2801 server->maxBuf - sizeof(WRITE_REQ) + 4);
2791 2802
2792 /* hard limit of CIFS_MAX_WSIZE */ 2803 /* hard limit of CIFS_MAX_WSIZE */
2793 wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE); 2804 wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE);
@@ -2937,7 +2948,11 @@ int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data,
2937 2948
2938 if (volume_info->nullauth) { 2949 if (volume_info->nullauth) {
2939 cFYI(1, "null user"); 2950 cFYI(1, "null user");
2940 volume_info->username = ""; 2951 volume_info->username = kzalloc(1, GFP_KERNEL);
2952 if (volume_info->username == NULL) {
2953 rc = -ENOMEM;
2954 goto out;
2955 }
2941 } else if (volume_info->username) { 2956 } else if (volume_info->username) {
2942 /* BB fixme parse for domain name here */ 2957 /* BB fixme parse for domain name here */
2943 cFYI(1, "Username: %s", volume_info->username); 2958 cFYI(1, "Username: %s", volume_info->username);
@@ -2971,8 +2986,7 @@ out:
2971} 2986}
2972 2987
2973int 2988int
2974cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, 2989cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info)
2975 struct smb_vol *volume_info, const char *devname)
2976{ 2990{
2977 int rc = 0; 2991 int rc = 0;
2978 int xid; 2992 int xid;
@@ -2983,6 +2997,13 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2983 struct tcon_link *tlink; 2997 struct tcon_link *tlink;
2984#ifdef CONFIG_CIFS_DFS_UPCALL 2998#ifdef CONFIG_CIFS_DFS_UPCALL
2985 int referral_walks_count = 0; 2999 int referral_walks_count = 0;
3000
3001 rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY);
3002 if (rc)
3003 return rc;
3004
3005 cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;
3006
2986try_mount_again: 3007try_mount_again:
2987 /* cleanup activities if we're chasing a referral */ 3008 /* cleanup activities if we're chasing a referral */
2988 if (referral_walks_count) { 3009 if (referral_walks_count) {
@@ -3007,6 +3028,7 @@ try_mount_again:
3007 srvTcp = cifs_get_tcp_session(volume_info); 3028 srvTcp = cifs_get_tcp_session(volume_info);
3008 if (IS_ERR(srvTcp)) { 3029 if (IS_ERR(srvTcp)) {
3009 rc = PTR_ERR(srvTcp); 3030 rc = PTR_ERR(srvTcp);
3031 bdi_destroy(&cifs_sb->bdi);
3010 goto out; 3032 goto out;
3011 } 3033 }
3012 3034
@@ -3018,14 +3040,6 @@ try_mount_again:
3018 goto mount_fail_check; 3040 goto mount_fail_check;
3019 } 3041 }
3020 3042
3021 if (pSesInfo->capabilities & CAP_LARGE_FILES)
3022 sb->s_maxbytes = MAX_LFS_FILESIZE;
3023 else
3024 sb->s_maxbytes = MAX_NON_LFS;
3025
3026 /* BB FIXME fix time_gran to be larger for LANMAN sessions */
3027 sb->s_time_gran = 100;
3028
3029 /* search for existing tcon to this server share */ 3043 /* search for existing tcon to this server share */
3030 tcon = cifs_get_tcon(pSesInfo, volume_info); 3044 tcon = cifs_get_tcon(pSesInfo, volume_info);
3031 if (IS_ERR(tcon)) { 3045 if (IS_ERR(tcon)) {
@@ -3038,7 +3052,7 @@ try_mount_again:
3038 if (tcon->ses->capabilities & CAP_UNIX) { 3052 if (tcon->ses->capabilities & CAP_UNIX) {
3039 /* reset of caps checks mount to see if unix extensions 3053 /* reset of caps checks mount to see if unix extensions
3040 disabled for just this mount */ 3054 disabled for just this mount */
3041 reset_cifs_unix_caps(xid, tcon, sb, volume_info); 3055 reset_cifs_unix_caps(xid, tcon, cifs_sb, volume_info);
3042 if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) && 3056 if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) &&
3043 (le64_to_cpu(tcon->fsUnixInfo.Capability) & 3057 (le64_to_cpu(tcon->fsUnixInfo.Capability) &
3044 CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)) { 3058 CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)) {
@@ -3161,6 +3175,7 @@ mount_fail_check:
3161 cifs_put_smb_ses(pSesInfo); 3175 cifs_put_smb_ses(pSesInfo);
3162 else 3176 else
3163 cifs_put_tcp_session(srvTcp); 3177 cifs_put_tcp_session(srvTcp);
3178 bdi_destroy(&cifs_sb->bdi);
3164 goto out; 3179 goto out;
3165 } 3180 }
3166 3181
@@ -3335,8 +3350,8 @@ CIFSTCon(unsigned int xid, struct cifs_ses *ses,
3335 return rc; 3350 return rc;
3336} 3351}
3337 3352
3338int 3353void
3339cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) 3354cifs_umount(struct cifs_sb_info *cifs_sb)
3340{ 3355{
3341 struct rb_root *root = &cifs_sb->tlink_tree; 3356 struct rb_root *root = &cifs_sb->tlink_tree;
3342 struct rb_node *node; 3357 struct rb_node *node;
@@ -3357,7 +3372,10 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
3357 } 3372 }
3358 spin_unlock(&cifs_sb->tlink_tree_lock); 3373 spin_unlock(&cifs_sb->tlink_tree_lock);
3359 3374
3360 return 0; 3375 bdi_destroy(&cifs_sb->bdi);
3376 kfree(cifs_sb->mountdata);
3377 unload_nls(cifs_sb->local_nls);
3378 kfree(cifs_sb);
3361} 3379}
3362 3380
3363int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses) 3381int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses)