From patchwork Fri Aug 22 22:20:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 4767381 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 CB048C0338 for ; Fri, 22 Aug 2014 22:21:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F324A2013A for ; Fri, 22 Aug 2014 22:21:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DC4F2012F for ; Fri, 22 Aug 2014 22:21:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302AbaHVWVI (ORCPT ); Fri, 22 Aug 2014 18:21:08 -0400 Received: from mail-oi0-f51.google.com ([209.85.218.51]:39871 "EHLO mail-oi0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752158AbaHVWVH (ORCPT ); Fri, 22 Aug 2014 18:21:07 -0400 Received: by mail-oi0-f51.google.com with SMTP id v63so1185465oia.10 for ; Fri, 22 Aug 2014 15:21:07 -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=IM6mbHIHgRka3uyKTG/x82uGB7SgCNWSHKOjWm3hG6k=; b=TNOCGyEzlUF2181NEX2ZT6quxiD54LPndKNaNkO1qXdAbMaSdinLl7p7zwJjXa9eKg 545ZyTpNg5i7GbRPC/DGdtTj22fAN4TqgfxhFPWHTHKkxc0Te2WDb4qSoilJPa4nVOsF ra/fkiof4KdxL8XlmVgJyxtHm8eJBvDc49FvsijhkXy8e9AWl7tujGDsE6jxF/+AihBo k9lUVruAi0zknu0ZKr3NlPMYr6vfbW3I/HJu0S7N0yuKwzL4OlBxWAs3o0kM2kgT6nBy i1+0wUsNCkSoDrHF9ju7nro/evnmEehjzXXpDfsh2h0bJiCj2xOD9aCDy4+OaU4hN7CO QweA== X-Received: by 10.60.121.67 with SMTP id li3mr5666866oeb.17.1408746066978; Fri, 22 Aug 2014 15:21:06 -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 uq2sm33090237obc.9.2014.08.22.15.21.05 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 15:21:06 -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 2/5] cifs: shared-superblock - data structures and functions for disconnected roots noserverino kind shares Date: Fri, 22 Aug 2014 17:20:59 -0500 Message-Id: <1408746059-10184-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 For servers that do not provide an uniqueid for inode, if we are mounting using a disconnected root dentry, keep a list of such dentries and other info in a linked list off of superblock. They can be searched and spliced within a spinlock or if never spliced, remembered to be removed. Signed-off-by: Shirish Pargaonkar --- fs/cifs/cifs_fs_sb.h | 10 ++++++++++ fs/cifs/cifsfs.c | 32 ++++++++++++++++++++++++++++++++ fs/cifs/connect.c | 3 +++ 3 files changed, 45 insertions(+) diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h index 9409fa1..ecc63af 100644 --- a/fs/cifs/cifs_fs_sb.h +++ b/fs/cifs/cifs_fs_sb.h @@ -66,5 +66,15 @@ struct cifs_sb_info { struct backing_dev_info bdi; struct delayed_work prune_tlinks; struct rcu_head rcu; + struct list_head rtdislist; /* list of disconnected root dentries */ + spinlock_t rtdislock; /* lock for disconnected root dentry list */ +}; + +struct cifs_rdelem { + int rdcount; + struct list_head rdlist; + char * rdname; + struct dentry * rdentry; + struct inode * rdinode; }; #endif /* _CIFS_FS_SB_H */ diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 0a4a4d7..4e759f6 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -570,6 +570,38 @@ static const struct super_operations cifs_super_ops = { #endif }; +void +cifs_free_rdelem(struct cifs_rdelem *rdelem) +{ + kfree(rdelem->rdname); + kfree(rdelem); +} + +struct cifs_rdelem * +cifs_alloc_rdelem(char *full_path, struct dentry *rdentry, + struct inode *rdinode) +{ + struct cifs_rdelem *rdelem; + + rdelem = kmalloc(sizeof(struct cifs_rdelem), GFP_KERNEL); + if (!rdelem) { + cifs_dbg(FYI, "%s Can't allocate root dentry\n", __func__); + return ERR_PTR(-ENOMEM); + } + + rdelem->rdname = kstrdup(full_path, GFP_KERNEL); + if (!rdelem->rdname) { + cifs_dbg(FYI, "%s Can't allocate root dentry name\n", __func__); + kfree(rdelem); + return ERR_PTR(-ENOMEM); + } + + rdelem->rdinode = rdinode; + rdelem->rdentry = rdentry; + + return rdelem; +} + /* * Get root dentry from superblock according to prefix path mount option. * Return dentry with refcount + 1 on success and NULL otherwise. diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 03ed8a0..2293b9d 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -3171,6 +3171,9 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, spin_lock_init(&cifs_sb->tlink_tree_lock); cifs_sb->tlink_tree = RB_ROOT; + spin_lock_init(&cifs_sb->rtdislock); + INIT_LIST_HEAD(&cifs_sb->rtdislist); + /* * Temporarily set r/wsize for matching superblock. If we end up using * new sb then client will later negotiate it downward if needed.