From patchwork Mon Mar 28 10:19:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Finney X-Patchwork-Id: 681011 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p31CRJio031907 for ; Fri, 1 Apr 2011 12:27:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754271Ab1DAM1U (ORCPT ); Fri, 1 Apr 2011 08:27:20 -0400 Received: from seldrel01.sonyericsson.com ([212.209.106.2]:14824 "EHLO seldrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753549Ab1DAM1S (ORCPT ); Fri, 1 Apr 2011 08:27:18 -0400 Message-ID: In-Reply-To: <20110401073256.70180710@tlielax.poochiereds.net> References: <20110401073256.70180710@tlielax.poochiereds.net> From: Sean Finney Date: Mon, 28 Mar 2011 12:19:29 +0200 Subject: [PATCH 4/4] Simplify handling of submount options in cifs_mount. To: linux-cifs@vger.kernel.org MIME-Version: 1.0 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 01 Apr 2011 12:27:20 +0000 (UTC) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 7d1d0e9..d8e300e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2756,9 +2756,9 @@ build_unc_path_to_root(const struct smb_vol *volume_info, /* * Perform a dfs referral query for a share and (optionally) prefix * - * If a referral is found, mount_data will be set to point at a newly - * allocated string containing updated options for the submount. - * Otherwise it will be left untouched. + * If a referral is found, cifs_sb->mountdata will be (re-)allocated + * to a string containing updated options for the submount. Otherwise it + * will be left untouched. * * Returns the rc from get_dfs_path to the caller, which can be used to * determine whether there were referrals. @@ -2766,7 +2766,7 @@ build_unc_path_to_root(const struct smb_vol *volume_info, static int expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, struct smb_vol *volume_info, struct cifs_sb_info *cifs_sb, - char **mount_data, int check_prefix) + int check_prefix) { int rc; unsigned int num_referrals = 0; @@ -2794,11 +2794,14 @@ expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, 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; } - *mount_data = mdata; + cifs_sb->mountdata = mdata; } kfree(full_path); return rc; @@ -2821,6 +2824,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, #ifdef CONFIG_CIFS_DFS_UPCALL int referral_walks_count = 0; try_mount_again: + mount_data = cifs_sb->mountdata; /* cleanup activities if we're chasing a referral */ if (referral_walks_count) { @@ -2954,7 +2958,7 @@ remote_path_check: */ if (referral_walks_count == 0) { int refrc = expand_dfs_referral(xid, pSesInfo, volume_info, - cifs_sb, &mount_data, false); + cifs_sb, false); if (!refrc) { referral_walks_count++; goto try_mount_again; @@ -2996,17 +3000,13 @@ remote_path_check: convert_delimiter(cifs_sb->prepath, CIFS_DIR_SEP(cifs_sb)); - if (mount_data != mount_data_global) - kfree(mount_data); - rc = expand_dfs_referral(xid, pSesInfo, volume_info, cifs_sb, - &mount_data, true); + true); if (!rc) { referral_walks_count++; goto try_mount_again; } - mount_data = NULL; goto mount_fail_check; #else /* No DFS support, return error on mount */ rc = -EOPNOTSUPP; @@ -3040,8 +3040,6 @@ remote_path_check: mount_fail_check: /* on error free sesinfo and tcon struct if needed */ if (rc) { - if (mount_data != mount_data_global) - kfree(mount_data); /* If find_unc succeeded then rc == 0 so we can not end */ /* up accidently freeing someone elses tcon struct */ if (tcon)