From patchwork Fri Aug 22 22:21:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 4767401 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BE8CCC0338 for ; Fri, 22 Aug 2014 22:21:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E4A332013A for ; Fri, 22 Aug 2014 22:21:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 088A12012F for ; Fri, 22 Aug 2014 22:21:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752272AbaHVWVi (ORCPT ); Fri, 22 Aug 2014 18:21:38 -0400 Received: from mail-oa0-f50.google.com ([209.85.219.50]:65119 "EHLO mail-oa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751716AbaHVWVh (ORCPT ); Fri, 22 Aug 2014 18:21:37 -0400 Received: by mail-oa0-f50.google.com with SMTP id g18so9133701oah.37 for ; Fri, 22 Aug 2014 15:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=5CsZ4y36joqk8/CHueee/dhhOaihMgdpKgcIcValp7c=; b=mxhXi4Z8ozi68/NsVycbA0AFnEdyzsx/QFHh+lnJ72ctis6qPjuFuLrvk5YyfSPA9i bjt6DVYRUjVhTwpSJS5u3yi6hq1VxzNlRMBArOtMgIXTg4QGU8Uc/e0Bs4EJsfcwSKsc zfFfYwkxl+V5I5/UkR4wpHZt/fFDrWQHqOBvXZ8PHeGcPkm6JnGx9EVgNkw06l934mIv kA2Zn9WAl4AVkX101Z7nu3xAcozJXXp0qF5naZLDHW/8J3XRQPeAzoQXCL1eKy37yuLw F7niCWup7hhFAr0CRfwE2UqTmyAEzLbnUtC9gQNCLJg614G3lCR7uoSY/KRH9lZsJVC/ P13g== X-Received: by 10.60.121.67 with SMTP id li3mr5668515oeb.17.1408746096880; Fri, 22 Aug 2014 15:21:36 -0700 (PDT) Received: from shirish-ThinkPad-T400.gns.novell.com (75-13-85-90.lightspeed.austtx.sbcglobal.net. [75.13.85.90]) by mx.google.com with ESMTPSA id q3sm44136687oei.3.2014.08.22.15.21.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 15:21:35 -0700 (PDT) From: shirishpargaonkar@gmail.com X-Google-Original-From: spargaonkar@suse.com To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, shirish , Shirish Pargaonkar Subject: [PATCH 4/5] cifs: shared-superblock - create a dentry as a disconnected root Date: Fri, 22 Aug 2014 17:21:28 -0500 Message-Id: <1408746088-10261-1-git-send-email-spargaonkar@suse.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: shirish Create a disconnected root dentry if to an authenticated user, the leaf directory of a mount is accessible but one or more intermediate paths are not. In case a server does not provide uniqueid, insert an element for the disconnected root dentry in a linked list off of superblock. Signed-off-by: Shirish Pargaonkar --- fs/cifs/cifsfs.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 4e759f6..0942622 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -602,6 +602,46 @@ cifs_alloc_rdelem(char *full_path, struct dentry *rdentry, return rdelem; } +static struct dentry * +create_root_dis_dentry(struct super_block *sb, struct inode *rinode, + char *fpath) +{ + int rc; + unsigned int xid; + struct dentry *dentry = NULL; + struct cifs_rdelem *rdelem = NULL; + struct cifs_sb_info *cifs_sb = CIFS_SB(sb); + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); + + xid = get_xid(); + if (tcon->unix_ext) + rc = cifs_get_inode_info_unix(&rinode, fpath, sb, xid); + else + rc = cifs_get_inode_info(&rinode, fpath, NULL, sb, xid, NULL); + free_xid(xid); + + if ((rc == 0) && (rinode != NULL)) { + dentry = d_obtain_alias(rinode); + if (IS_ERR(dentry)) { + iput(rinode); + goto rdelem_ret; + } + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { + rdelem = + cifs_alloc_rdelem(fpath, dentry, rinode); + if (IS_ERR(rdelem)) + goto rdelem_ret; + spin_lock(&cifs_sb->rtdislock); + list_add(&rdelem->rdlist, &cifs_sb->rtdislist); + spin_unlock(&cifs_sb->rtdislock); + } + return dentry; + } + +rdelem_ret: + return ERR_PTR(-EACCES); +} + /* * Get root dentry from superblock according to prefix path mount option. * Return dentry with refcount + 1 on success and NULL otherwise. @@ -614,9 +654,10 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) char *full_path = NULL; char *s, *p; char sep; + struct inode *rinode = NULL; + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); - full_path = cifs_build_path_to_root(vol, cifs_sb, - cifs_sb_master_tcon(cifs_sb)); + full_path = cifs_build_path_to_root(vol, cifs_sb, tcon); if (full_path == NULL) return ERR_PTR(-ENOMEM); @@ -657,6 +698,10 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) dput(dentry); dentry = child; } while (!IS_ERR(dentry)); + + if (IS_ERR(dentry) && (PTR_ERR(dentry) == -EACCES) && *s) + dentry = create_root_dis_dentry(sb, rinode, full_path); + kfree(full_path); return dentry; }