Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6:
cifs: drop spinlock before calling cifs_put_tlink
cifs: fix expand_dfs_referral
cifs: move bdi_setup_and_register outside of CONFIG_CIFS_DFS_UPCALL
cifs: factor smb_vol allocation out of cifs_setup_volume_info
cifs: have cifs_cleanup_volume_info not take a double pointer
cifs: fix build_unc_path_to_root to account for a prefixpath
cifs: remove bogus call to cifs_cleanup_volume_info

+74 -58
+4 -4
fs/cifs/cifsfs.c
··· 649 649 650 650 cFYI(1, "Devname: %s flags: %d ", dev_name, flags); 651 651 652 - rc = cifs_setup_volume_info(&volume_info, (char *)data, dev_name); 653 - if (rc) 654 - return ERR_PTR(rc); 652 + volume_info = cifs_get_volume_info((char *)data, dev_name); 653 + if (IS_ERR(volume_info)) 654 + return ERR_CAST(volume_info); 655 655 656 656 cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL); 657 657 if (cifs_sb == NULL) { ··· 713 713 out_super: 714 714 deactivate_locked_super(sb); 715 715 out: 716 - cifs_cleanup_volume_info(&volume_info); 716 + cifs_cleanup_volume_info(volume_info); 717 717 return root; 718 718 719 719 out_mountdata:
+3 -3
fs/cifs/cifsproto.h
··· 154 154 extern void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, 155 155 struct cifs_sb_info *cifs_sb); 156 156 extern int cifs_match_super(struct super_block *, void *); 157 - extern void cifs_cleanup_volume_info(struct smb_vol **pvolume_info); 158 - extern int cifs_setup_volume_info(struct smb_vol **pvolume_info, 159 - char *mount_data, const char *devname); 157 + extern void cifs_cleanup_volume_info(struct smb_vol *pvolume_info); 158 + extern struct smb_vol *cifs_get_volume_info(char *mount_data, 159 + const char *devname); 160 160 extern int cifs_mount(struct cifs_sb_info *, struct smb_vol *); 161 161 extern void cifs_umount(struct cifs_sb_info *); 162 162 extern void cifs_dfs_release_automount_timer(void);
+67 -51
fs/cifs/connect.c
··· 65 65 static int generic_ip_connect(struct TCP_Server_Info *server); 66 66 static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink); 67 67 static void cifs_prune_tlinks(struct work_struct *work); 68 + static int cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, 69 + const char *devname); 68 70 69 71 /* 70 72 * cifs tcp session reconnection ··· 2242 2240 2243 2241 rc = compare_mount_options(sb, mnt_data); 2244 2242 out: 2245 - cifs_put_tlink(tlink); 2246 2243 spin_unlock(&cifs_tcp_ses_lock); 2244 + cifs_put_tlink(tlink); 2247 2245 return rc; 2248 2246 } 2249 2247 ··· 2832 2830 return rc; 2833 2831 } 2834 2832 2835 - void 2836 - cifs_cleanup_volume_info(struct smb_vol **pvolume_info) 2833 + static void 2834 + cleanup_volume_info_contents(struct smb_vol *volume_info) 2837 2835 { 2838 - struct smb_vol *volume_info; 2839 - 2840 - if (!pvolume_info || !*pvolume_info) 2841 - return; 2842 - 2843 - volume_info = *pvolume_info; 2844 2836 kfree(volume_info->username); 2845 2837 kzfree(volume_info->password); 2846 2838 kfree(volume_info->UNC); ··· 2842 2846 kfree(volume_info->domainname); 2843 2847 kfree(volume_info->iocharset); 2844 2848 kfree(volume_info->prepath); 2845 - kfree(volume_info); 2846 - *pvolume_info = NULL; 2847 - return; 2848 2849 } 2850 + 2851 + void 2852 + cifs_cleanup_volume_info(struct smb_vol *volume_info) 2853 + { 2854 + if (!volume_info) 2855 + return; 2856 + cleanup_volume_info_contents(volume_info); 2857 + kfree(volume_info); 2858 + } 2859 + 2849 2860 2850 2861 #ifdef CONFIG_CIFS_DFS_UPCALL 2851 2862 /* build_path_to_root returns full path to root when 2852 2863 * we do not have an exiting connection (tcon) */ 2853 2864 static char * 2854 - build_unc_path_to_root(const struct smb_vol *volume_info, 2865 + build_unc_path_to_root(const struct smb_vol *vol, 2855 2866 const struct cifs_sb_info *cifs_sb) 2856 2867 { 2857 - char *full_path; 2868 + char *full_path, *pos; 2869 + unsigned int pplen = vol->prepath ? strlen(vol->prepath) : 0; 2870 + unsigned int unc_len = strnlen(vol->UNC, MAX_TREE_SIZE + 1); 2858 2871 2859 - int unc_len = strnlen(volume_info->UNC, MAX_TREE_SIZE + 1); 2860 - full_path = kmalloc(unc_len + 1, GFP_KERNEL); 2872 + full_path = kmalloc(unc_len + pplen + 1, GFP_KERNEL); 2861 2873 if (full_path == NULL) 2862 2874 return ERR_PTR(-ENOMEM); 2863 2875 2864 - strncpy(full_path, volume_info->UNC, unc_len); 2865 - full_path[unc_len] = 0; /* add trailing null */ 2876 + strncpy(full_path, vol->UNC, unc_len); 2877 + pos = full_path + unc_len; 2878 + 2879 + if (pplen) { 2880 + strncpy(pos, vol->prepath, pplen); 2881 + pos += pplen; 2882 + } 2883 + 2884 + *pos = '\0'; /* add trailing null */ 2866 2885 convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb)); 2886 + cFYI(1, "%s: full_path=%s", __func__, full_path); 2867 2887 return full_path; 2868 2888 } 2869 2889 ··· 2922 2910 &fake_devname); 2923 2911 2924 2912 free_dfs_info_array(referrals, num_referrals); 2925 - kfree(fake_devname); 2926 - 2927 - if (cifs_sb->mountdata != NULL) 2928 - kfree(cifs_sb->mountdata); 2929 2913 2930 2914 if (IS_ERR(mdata)) { 2931 2915 rc = PTR_ERR(mdata); 2932 2916 mdata = NULL; 2917 + } else { 2918 + cleanup_volume_info_contents(volume_info); 2919 + memset(volume_info, '\0', sizeof(*volume_info)); 2920 + rc = cifs_setup_volume_info(volume_info, mdata, 2921 + fake_devname); 2933 2922 } 2923 + kfree(fake_devname); 2924 + kfree(cifs_sb->mountdata); 2934 2925 cifs_sb->mountdata = mdata; 2935 2926 } 2936 2927 kfree(full_path); ··· 2941 2926 } 2942 2927 #endif 2943 2928 2944 - int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, 2945 - const char *devname) 2929 + static int 2930 + cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, 2931 + const char *devname) 2946 2932 { 2947 - struct smb_vol *volume_info; 2948 2933 int rc = 0; 2949 2934 2950 - *pvolume_info = NULL; 2951 - 2952 - volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); 2953 - if (!volume_info) { 2954 - rc = -ENOMEM; 2955 - goto out; 2956 - } 2957 - 2958 - if (cifs_parse_mount_options(mount_data, devname, 2959 - volume_info)) { 2960 - rc = -EINVAL; 2961 - goto out; 2962 - } 2935 + if (cifs_parse_mount_options(mount_data, devname, volume_info)) 2936 + return -EINVAL; 2963 2937 2964 2938 if (volume_info->nullauth) { 2965 2939 cFYI(1, "null user"); 2966 2940 volume_info->username = kzalloc(1, GFP_KERNEL); 2967 - if (volume_info->username == NULL) { 2968 - rc = -ENOMEM; 2969 - goto out; 2970 - } 2941 + if (volume_info->username == NULL) 2942 + return -ENOMEM; 2971 2943 } else if (volume_info->username) { 2972 2944 /* BB fixme parse for domain name here */ 2973 2945 cFYI(1, "Username: %s", volume_info->username); ··· 2962 2960 cifserror("No username specified"); 2963 2961 /* In userspace mount helper we can get user name from alternate 2964 2962 locations such as env variables and files on disk */ 2965 - rc = -EINVAL; 2966 - goto out; 2963 + return -EINVAL; 2967 2964 } 2968 2965 2969 2966 /* this is needed for ASCII cp to Unicode converts */ ··· 2974 2973 if (volume_info->local_nls == NULL) { 2975 2974 cERROR(1, "CIFS mount error: iocharset %s not found", 2976 2975 volume_info->iocharset); 2977 - rc = -ELIBACC; 2978 - goto out; 2976 + return -ELIBACC; 2979 2977 } 2980 2978 } 2981 2979 2982 - *pvolume_info = volume_info; 2983 2980 return rc; 2984 - out: 2985 - cifs_cleanup_volume_info(&volume_info); 2986 - return rc; 2981 + } 2982 + 2983 + struct smb_vol * 2984 + cifs_get_volume_info(char *mount_data, const char *devname) 2985 + { 2986 + int rc; 2987 + struct smb_vol *volume_info; 2988 + 2989 + volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); 2990 + if (!volume_info) 2991 + return ERR_PTR(-ENOMEM); 2992 + 2993 + rc = cifs_setup_volume_info(volume_info, mount_data, devname); 2994 + if (rc) { 2995 + cifs_cleanup_volume_info(volume_info); 2996 + volume_info = ERR_PTR(rc); 2997 + } 2998 + 2999 + return volume_info; 2987 3000 } 2988 3001 2989 3002 int ··· 3012 2997 struct tcon_link *tlink; 3013 2998 #ifdef CONFIG_CIFS_DFS_UPCALL 3014 2999 int referral_walks_count = 0; 3000 + #endif 3015 3001 3016 3002 rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY); 3017 3003 if (rc) ··· 3020 3004 3021 3005 cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages; 3022 3006 3007 + #ifdef CONFIG_CIFS_DFS_UPCALL 3023 3008 try_mount_again: 3024 3009 /* cleanup activities if we're chasing a referral */ 3025 3010 if (referral_walks_count) { ··· 3029 3012 else if (pSesInfo) 3030 3013 cifs_put_smb_ses(pSesInfo); 3031 3014 3032 - cifs_cleanup_volume_info(&volume_info); 3033 3015 FreeXid(xid); 3034 3016 } 3035 3017 #endif