cifs: fix regressions when chasing DFS referrals at mount time
Subsystems (2)
cover cifs: fix regressions when chasing DFS referrals at mount time
While the patch I posted yesterday fixes the oops that was occurring when the client tried to chase DFS referrals at mount time, doing so still didn't work.
The main culprit seems to be the shared-superblock patchset, which broke this in several different ways. This patchset fixes the problems for me and passes basic smoke testing.
Steve, please consider these for 3.0. I don't really like pushing a set this large close to release, but I don't see any alternative.
Jeff Layton (4):
cifs: fix build_unc_path_to_root to account for a prefixpath
cifs: have cifs_cleanup_volume_info not take a double pointer
cifs: factor smb_vol allocation out of cifs_setup_volume_info
cifs: fix expand_dfs_referral
fs/cifs/cifsfs.c | 8 ++-- fs/cifs/cifsproto.h | 6 +- fs/cifs/connect.c | 111 +++++++++++++++++++++++++++++---------------------- 3 files changed, 70 insertions(+), 55 deletions(-)
Signature · 1 line
1.7.6
A message that is not in the archive (sent off-list or not yet received): 1309954239-17345-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH 1/4 cifs: fix build_unc_path_to_root to account for a prefixpath
Regression introduced by commit f87d39d9513.
--- fs/cifs/connect.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-)
fs/cifs/connect.c +15 -6
@@ -2855,19 +2855,28 @@ cifs_cleanup_volume_info(struct smb_vol **pvolume_info)/* build_path_to_root returns full path to root when * we do not have an exiting connection (tcon) */ static char * -build_unc_path_to_root (const struct smb_vol *volume_info, +build_unc_path_to_root (const struct smb_vol *vol,const struct cifs_sb_info *cifs_sb) { -char *full_path; +char *full_path, *pos; +unsigned int pplen = vol->prepath ?strlen (vol->prepath) :0 ; +unsigned int unc_len =strnlen (vol->UNC,MAX_TREE_SIZE +1 ); -int unc_len =strnlen (volume_info->UNC,MAX_TREE_SIZE +1 ); - full_path =kmalloc (unc_len +1 ,GFP_KERNEL ); + full_path =kmalloc (unc_len + pplen +1 ,GFP_KERNEL );if (full_path ==NULL )return ERR_PTR (-ENOMEM ); -strncpy (full_path, volume_info->UNC, unc_len); - full_path[unc_len] =0 ;/* add trailing null */ +strncpy (full_path, vol->UNC, unc_len); + pos = full_path + unc_len; + +if (pplen) { +strncpy (pos, vol->prepath, pplen); + pos += pplen; + } + + *pos ='\0' ;/* add trailing null */ convert_delimiter (full_path,CIFS_DIR_SEP (cifs_sb)); +cFYI (1 ,"%s: full_path=%s" , __func__, full_path);return full_path; }
Signature · 1 line
1.7.6
A message that is not in the archive (sent off-list or not yet received): 1309954239-17345-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Pavel Shilovsky
Reviewed-byRe: [PATCH 1/4] cifs: fix build_unc_path_to_root to account for a prefixpath
2011/7/6 Jeff Layton <[email protected]>:
Quoted 46 lines
Regression introduced by commit
f87d39d9513.Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/connect.c | 21 +++++++++++++++------1 files changed, 15 insertions(+), 6 deletions(-)fs/cifs/connect.c +0
-0@@ -2855,19 +2855,28 @@ cifs_cleanup_volume_info(struct smb_vol **pvolume_info) /* build_path_to_root returns full path to root when* we do not have an exiting connection (tcon) */ static char *
fs/cifs/connect.c +1
-1-build_unc_path_to_root(const struct smb_vol *volume_info, +build_unc_path_to_root(const struct smb_vol *vol,const struct
cifs_sb_info*cifs_sb)
{
- char*full_path;
+ char*full_path, *pos;
+ unsigned int pplen =vol->prepath?strlen(vol->prepath): 0;
+ unsigned intunc_len=strnlen(vol->UNC, MAX_TREE_SIZE + 1);- int
unc_len=strnlen(volume_info->UNC, MAX_TREE_SIZE + 1);
-full_path=kmalloc(unc_len + 1, GFP_KERNEL);
+full_path=kmalloc(unc_len + pplen + 1, GFP_KERNEL); if (full_path== NULL)
returnERR_PTR(-ENOMEM);-
strncpy(full_path, volume_info->UNC, unc_len);
- full_path[unc_len] = 0; /* add trailing null */
+strncpy(full_path, vol->UNC, unc_len);
+ pos =full_path+unc_len;fs/cifs/connect.c +7
-0+ + if (pplen) { + strncpy(pos, vol->prepath, pplen); + pos += pplen; + } + + *pos = '\0'; /* add trailing null */convert_delimiter(full_path,
CIFS_DIR_SEP(cifs_sb));
+cFYI(1, "%s: full_path=%s", __func__, full_path); returnfull_path;
}
Quoted 4 lines
--
1.7.6
Ops, I missed it, thanks!
Signature · 2 lines
Best regards, Pavel Shilovsky.
PATCH 2/4 cifs: have cifs_cleanup_volume_info not take a double pointer
In reply to a message not in the archive...as that makes for a cumbersome interface. Make it take a regular smb_vol pointer and rely on the caller to zero it out if needed.
--- fs/cifs/cifsfs.c | 2 +- fs/cifs/cifsproto.h | 2 +- fs/cifs/connect.c | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-)
fs/cifs/cifsfs.c +1 -1
@@ -713,7 +713,7 @@ cifs_do_mount(struct file_system_type *fs_type, out_super:deactivate_locked_super (sb); out: -cifs_cleanup_volume_info (&volume_info); +cifs_cleanup_volume_info (volume_info);return root; out_mountdata:
fs/cifs/cifsproto.h +1 -1
@@ -154,7 +154,7 @@ extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *,extern void cifs_setup_cifs_sb (struct smb_vol *pvolume_info,struct cifs_sb_info *cifs_sb);extern int cifs_match_super (struct super_block *,void *); -extern void cifs_cleanup_volume_info (struct smb_vol **pvolume_info); +extern void cifs_cleanup_volume_info (struct smb_vol *pvolume_info);extern int cifs_setup_volume_info (struct smb_vol **pvolume_info,char *mount_data,const char *devname);extern int cifs_mount (struct cifs_sb_info *,struct smb_vol *);
fs/cifs/connect.c +3 -7
@@ -2831,14 +2831,11 @@ is_path_accessible(int xid, struct cifs_tcon *tcon, }void -cifs_cleanup_volume_info (struct smb_vol **pvolume_info) +cifs_cleanup_volume_info (struct smb_vol *volume_info) { -struct smb_vol *volume_info; - -if (!pvolume_info || !*pvolume_info) +if (!volume_info)return ; - volume_info = *pvolume_info;kfree (volume_info->username);kzfree (volume_info->password);kfree (volume_info->UNC);
@@ -2847,7 +2844,6 @@ cifs_cleanup_volume_info(struct smb_vol **pvolume_info)kfree (volume_info->iocharset);kfree (volume_info->prepath);kfree (volume_info); - *pvolume_info =NULL ;return ; }
@@ -2990,7 +2986,7 @@ int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, *pvolume_info = volume_info;return rc; out: -cifs_cleanup_volume_info (&volume_info); +cifs_cleanup_volume_info (volume_info);return rc; }
Signature · 1 line
1.7.6
A message that is not in the archive (sent off-list or not yet received): 1309954239-17345-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Pavel Shilovsky
Reviewed-byRe: [PATCH 2/4] cifs: have cifs_cleanup_volume_info not take a double pointer
2011/7/6 Jeff Layton <[email protected]>:
Quoted 74 lines
...as that makes for a cumbersome interface. Make it take a regular
smb_volpointer and rely on the caller to zero it out if needed.Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/cifsfs.c | 2 +-
fs/cifs/cifsproto.h | 2 +-
fs/cifs/connect.c | 10 +++-------3 files changed, 5 insertions(+), 9 deletions(-)fs/cifs/cifsfs.c +0
-0@@ -713,7 +713,7 @@ cifs_do_mount(struct file_system_type *fs_type,out_super:
deactivate_locked_super(sb);
out:
-cifs_cleanup_volume_info(&volume_info);
+cifs_cleanup_volume_info(volume_info);
return root;out_mountdata:
fs/cifs/cifsproto.h +1
-1@@ -154,7 +154,7 @@ extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *, extern void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, struct cifs_sb_info *cifs_sb); extern int cifs_match_super(struct super_block *, void *); -extern void cifs_cleanup_volume_info (struct smb_vol **pvolume_info); +extern void cifs_cleanup_volume_info (struct smb_vol *pvolume_info); extern int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, const char *devname); extern int cifs_mount(struct cifs_sb_info *, struct smb_vol *);fs/cifs/connect.c +0
-0@@ -2831,14 +2831,11 @@ is_path_accessible(int xid, struct cifs_tcon *tcon, }void
fs/cifs/connect.c +1
-1-cifs_cleanup_volume_info(struct smb_vol **pvolume_info) +cifs_cleanup_volume_info(struct smb_vol *volume_info){
- structsmb_vol*volume_info;
-
- if (!pvolume_info || !*pvolume_info)
+ if (!volume_info)
return;-
volume_info=*pvolume_info;
kfree(volume_info->username);
kzfree(volume_info->password);
kfree(volume_info->UNC);fs/cifs/connect.c +0
-1@@ -2847,7 +2844,6 @@ cifs_cleanup_volume_info(struct smb_vol **pvolume_info) kfree(volume_info->iocharset); kfree(volume_info->prepath); kfree(volume_info); - *pvolume_info = NULL; return; }@@ -2990,7 +2986,7 @@ int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, *pvolume_info = volume_info; return rc;out:
-cifs_cleanup_volume_info(&volume_info);
+cifs_cleanup_volume_info(volume_info);
return rc;
}
Quoted 4 lines
--
1.7.6
Signature · 2 lines
Best regards, Pavel Shilovsky.
PATCH 3/4 cifs: factor smb_vol allocation out of cifs_setup_volume_info
In reply to a message not in the archive--- fs/cifs/cifsfs.c | 6 ++-- fs/cifs/cifsproto.h | 4 +- fs/cifs/connect.c | 56 +++++++++++++++++++++++++------------------------- 3 files changed, 33 insertions(+), 33 deletions(-)
fs/cifs/cifsfs.c +3 -3
@@ -649,9 +649,9 @@ cifs_do_mount(struct file_system_type *fs_type,cFYI (1 ,"Devname: %s flags: %d " , dev_name, flags); - rc =cifs_setup_volume_info (&volume_info, (char *)data, dev_name); -if (rc) -return ERR_PTR (rc); + volume_info =cifs_get_volume_info ((char *)data, dev_name); +if (IS_ERR (volume_info)) +return ERR_CAST (volume_info); cifs_sb =kzalloc (sizeof (struct cifs_sb_info ),GFP_KERNEL );if (cifs_sb ==NULL ) {
fs/cifs/cifsproto.h +2 -2
@@ -155,8 +155,8 @@ extern void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, struct cifs_sb_info *cifs_sb);extern int cifs_match_super (struct super_block *,void *);extern void cifs_cleanup_volume_info (struct smb_vol *pvolume_info); -extern int cifs_setup_volume_info (struct smb_vol **pvolume_info, -char *mount_data,const char *devname); +extern struct smb_vol *cifs_get_volume_info (char *mount_data, +const char *devname);extern int cifs_mount (struct cifs_sb_info *,struct smb_vol *);extern void cifs_umount (struct cifs_sb_info *);extern void cifs_dfs_release_automount_timer (void );
fs/cifs/connect.c +28 -28
87 lines not on this page · raw message
Signature · 1 line
1.7.6
A message that is not in the archive (sent off-list or not yet received): 1309954239-17345-4-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Pavel Shilovsky
Reviewed-byRe: [PATCH 3/4] cifs: factor smb_vol allocation out of cifs_setup_volume_info
2011/7/6 Jeff Layton <[email protected]>:
Quoted 130 lines
Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/cifsfs.c | 6 ++--
fs/cifs/cifsproto.h | 4 +-
fs/cifs/connect.c | 56 +++++++++++++++++++++++++-------------------------3 files changed, 33 insertions(+), 33 deletions(-)fs/cifs/cifsfs.c +3
-3@@ -649,9 +649,9 @@ cifs_do_mount(struct file_system_type *fs_type, cFYI(1, "Devname: %s flags: %d ", dev_name, flags); - rc = cifs_setup_volume_info(&volume_info, (char *)data, dev_name); - if (rc) - return ERR_PTR(rc); + volume_info = cifs_get_volume_info((char *)data, dev_name); + if (IS_ERR(volume_info)) + return ERR_CAST(volume_info); cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL); if (cifs_sb == NULL) {fs/cifs/cifsproto.h +2
-2@@ -155,8 +155,8 @@ extern void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, struct cifs_sb_info *cifs_sb); extern int cifs_match_super(struct super_block *, void *); extern void cifs_cleanup_volume_info(struct smb_vol *pvolume_info); -extern int cifs_setup_volume_info (struct smb_vol **pvolume_info, - char *mount_data, const char *devname); +extern struct smb_vol *cifs_get_volume_info (char *mount_data, + const char *devname); extern int cifs_mount(struct cifs_sb_info *, struct smb_vol *); extern void cifs_umount(struct cifs_sb_info *); extern void cifs_dfs_release_automount_timer(void);fs/cifs/connect.c +7
-20@@ -2931,33 +2931,20 @@ expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, } #endif -int cifs_setup_volume_info (struct smb_vol **pvolume_info,char *mount_data, - const char *devname) +static int +cifs_setup_volume_info (struct smb_vol *volume_info,char *mount_data, + const char *devname) { - struct smb_vol *volume_info; int rc = 0; - *pvolume_info = NULL; - - volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); - if (!volume_info) { - rc = -ENOMEM; - goto out; - } - - if (cifs_parse_mount_options(mount_data, devname, - volume_info)) { - rc = -EINVAL; - goto out; - } + if (cifs_parse_mount_options(mount_data, devname, volume_info)) + return -EINVAL; if (volume_info->nullauth) { cFYI(1, "null user"); volume_info->username = kzalloc(1, GFP_KERNEL); - if (volume_info->username == NULL) { - rc = -ENOMEM; - goto out; - } + if (volume_info->username == NULL) + return -ENOMEM; } else if (volume_info->username) { /* BB fixme parse for domain name here */ cFYI(1, "Username: %s", volume_info->username);@@ -2965,8 +2952,7 @@ int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, cifserror("No username specified"); /* In userspace mount helper we can get user name from alternatelocations such as env variables and files on disk */
- rc =-EINVAL;
- goto out;
+ return-EINVAL;
}/* this is needed for ASCII cp to Unicode converts */
fs/cifs/connect.c +20
-6@@ -2978,18 +2964,32 @@ int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, if (volume_info->local_nls == NULL) { cERROR(1, "CIFS mount error: iocharset %s not found", volume_info->iocharset); - rc = -ELIBACC; - goto out; + return -ELIBACC; } } - *pvolume_info = volume_info; - return rc; -out: - cifs_cleanup_volume_info(volume_info); return rc; } +struct smb_vol * +cifs_get_volume_info (char *mount_data,const char *devname) +{ + int rc; + struct smb_vol *volume_info; + + volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); + if (!volume_info) + return ERR_PTR(-ENOMEM); + + rc = cifs_setup_volume_info(volume_info, mount_data, devname); + if (rc) { + cifs_cleanup_volume_info(volume_info); + volume_info = ERR_PTR(rc); + } + + return volume_info; +} +
Quoted 7 lines
int
cifs_mount(structcifs_sb_info*cifs_sb, structsmb_vol*volume_info) {
--
1.7.6
Signature · 2 lines
Best regards, Pavel Shilovsky.
PATCH 4/4 cifs: fix expand_dfs_referral
In reply to a message not in the archiveRegression introduced in commit 724d9f1cfba.
Prior to that, expand_dfs_referral would regenerate the mount data string and then call cifs_parse_mount_options to re-parse it (klunky, but it worked). The above commit moved cifs_parse_mount_options out of cifs_mount, so the re-parsing of the new mount options no longer occurred. Fix it by making expand_dfs_referral re-parse the mount options.
--- fs/cifs/connect.c | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-)
fs/cifs/connect.c +20 -10
@@ -65,6 +65,8 @@ static int ip_connect(struct TCP_Server_Info *server);static int generic_ip_connect (struct TCP_Server_Info *server);static void tlink_rb_insert (struct rb_root *root,struct tcon_link *new_tlink);static void cifs_prune_tlinks (struct work_struct *work); +static int cifs_setup_volume_info (struct smb_vol *volume_info,char *mount_data, +const char *devname);/* * cifs tcp session reconnection
@@ -2830,12 +2832,9 @@ is_path_accessible(int xid, struct cifs_tcon *tcon,return rc; } -void -cifs_cleanup_volume_info (struct smb_vol *volume_info) +static void +cleanup_volume_info_contents (struct smb_vol *volume_info) { -if (!volume_info) -return ; -kfree (volume_info->username);kzfree (volume_info->password);kfree (volume_info->UNC);
@@ -2843,10 +2842,18 @@ cifs_cleanup_volume_info(struct smb_vol *volume_info)kfree (volume_info->domainname);kfree (volume_info->iocharset);kfree (volume_info->prepath); +} + +void +cifs_cleanup_volume_info (struct smb_vol *volume_info) +{ +if (!volume_info) +return ; +cleanup_volume_info_contents (volume_info);kfree (volume_info); -return ; } +#ifdef CONFIG_CIFS_DFS_UPCALL /* build_path_to_root returns full path to root when * we do not have an exiting connection (tcon) */
@@ -2915,15 +2922,18 @@ expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, &fake_devname);free_dfs_info_array (referrals, num_referrals); -kfree (fake_devname); - -if (cifs_sb->mountdata !=NULL ) -kfree (cifs_sb->mountdata);if (IS_ERR (mdata)) { rc =PTR_ERR (mdata); mdata =NULL ; + }else { +cleanup_volume_info_contents (volume_info); +memset (volume_info,'\0' ,sizeof (*volume_info)); + rc =cifs_setup_volume_info (volume_info, mdata, + fake_devname); } +kfree (fake_devname); +kfree (cifs_sb->mountdata); cifs_sb->mountdata = mdata; }kfree (full_path);
Signature · 1 line
1.7.6
A message that is not in the archive (sent off-list or not yet received): 1309954239-17345-5-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Pavel Shilovsky
Reviewed-byRe: [PATCH 4/4] cifs: fix expand_dfs_referral
2011/7/6 Jeff Layton <[email protected]>:
Quoted 85 lines
Regression introduced in commit
724d9f1cfba.Prior to that,
expand_dfs_referralwould regenerate the mount data string and then callcifs_parse_mount_optionsto re-parse it (klunky, but it worked). The above commit movedcifs_parse_mount_optionsout ofcifs_mount, so the re-parsing of the new mount options no longer occurred. Fix it by makingexpand_dfs_referralre-parse the mount options.Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/connect.c | 30 ++++++++++++++++++++----------1 files changed, 20 insertions(+), 10 deletions(-)fs/cifs/connect.c +20
-11@@ -65,6 +65,8 @@ static int ip_connect(struct TCP_Server_Info *server); static int generic_ip_connect(struct TCP_Server_Info *server); static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink); static void cifs_prune_tlinks(struct work_struct *work); +static int cifs_setup_volume_info (struct smb_vol *volume_info,char *mount_data, + const char *devname); /** cifs tcp session reconnection @@ -2830,12 +2832,9 @@ is_path_accessible(int xid, struct cifs_tcon *tcon, return rc; } -void -cifs_cleanup_volume_info (struct smb_vol *volume_info) +static void +cleanup_volume_info_contents (struct smb_vol *volume_info) { - if (!volume_info) - return; - kfree(volume_info->username); kzfree(volume_info->password); kfree(volume_info->UNC);@@ -2843,10 +2842,18 @@ cifs_cleanup_volume_info(struct smb_vol *volume_info) kfree(volume_info->domainname); kfree(volume_info->iocharset); kfree(volume_info->prepath); +} + +void +cifs_cleanup_volume_info (struct smb_vol *volume_info) +{ + if (!volume_info) + return; + cleanup_volume_info_contents(volume_info); kfree(volume_info); - return; } + #ifdef CONFIG_CIFS_DFS_UPCALL /* build_path_to_root returns full path to root when* we do not have an exiting connection (tcon) */ @@ -2915,15 +2922,18 @@ expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, &fake_devname); free_dfs_info_array(referrals, num_referrals); - kfree(fake_devname); - - if (cifs_sb->mountdata != NULL) - kfree(cifs_sb->mountdata); if (IS_ERR(mdata)) { rc = PTR_ERR(mdata); mdata = NULL; + } else { + cleanup_volume_info_contents(volume_info); + memset(volume_info, '\0', sizeof(*volume_info)); + rc = cifs_setup_volume_info(volume_info, mdata, + fake_devname); } + kfree(fake_devname); + kfree(cifs_sb->mountdata); cifs_sb->mountdata = mdata; } kfree(full_path); --
Quoted 3 lines
1.7.6
Signature · 2 lines
Best regards, Pavel Shilovsky.