From patchwork Fri Mar 4 23:18:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sage Weil X-Patchwork-Id: 610431 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 p24NH3um032538 for ; Fri, 4 Mar 2011 23:17:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932733Ab1CDXRB (ORCPT ); Fri, 4 Mar 2011 18:17:01 -0500 Received: from cobra.newdream.net ([66.33.216.30]:56485 "EHLO cobra.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932655Ab1CDXRA (ORCPT ); Fri, 4 Mar 2011 18:17:00 -0500 Received: from cobra.newdream.net (localhost [127.0.0.1]) by cobra.newdream.net (Postfix) with ESMTP id 783B1BC71A; Fri, 4 Mar 2011 15:18:57 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=newdream.net; h=date:from:to:cc :subject:message-id:mime-version:content-type; q=dns; s= newdream.net; b=uDGjdKlWJ9IPlKqjfRTdkgjyKcKtxKV+w961N/bsDcj3yB4H HWo6zL7C/g7ruyEUkYivL4SJ4c1MqaAGboXI59ceMJQyDWfg2CxE8f2nSBn2VKlC syiuqs7vXAKdIL0ruro1ySJlp4efvY4ij39MLcclzJo8Ty4RL1dlzlut5ps= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=newdream.net; h=date:from :to:cc:subject:message-id:mime-version:content-type; s= newdream.net; bh=F5zxaSnnBe8DGTdRlW8SCCiuM88=; b=wNeWBXOfUg260oT VIcFjQ6w7lpw1nAnAdEbB3vDvLorT6Q081a+JRORFpDrURzMB8BX0CT+PhpKqeNj jf3Ik4X8qElp/MyKTlIUwcvT0sQsjgKJDHyD8QtBpiDATojW+pRp0rEn2Fz20uD8 mTUVugZadcRiTmz3LtHKSUn0MFkc= Received: by cobra.newdream.net (Postfix, from userid 1031) id 65C0EBC72C; Fri, 4 Mar 2011 15:18:57 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by cobra.newdream.net (Postfix) with ESMTP id 4FBD6BC71A; Fri, 4 Mar 2011 15:18:57 -0800 (PST) Date: Fri, 4 Mar 2011 15:18:57 -0800 (PST) From: Sage Weil To: linux-fsdevel@vger.kernel.org, ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org cc: Al Viro Subject: [RFC] d_prune Message-ID: MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@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, 04 Mar 2011 23:17:03 +0000 (UTC) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 4471a41..180e14b 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -28,6 +28,7 @@ d_revalidate: no no yes (ref-walk) maybe d_hash no no no maybe d_compare: yes no no maybe d_delete: no yes no no +d_prune: no yes no no d_release: no no yes no d_iput: no no yes no d_dname: no no no no diff --git a/fs/dcache.c b/fs/dcache.c index 2a6bd9a..cdb5d81 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -690,6 +690,8 @@ static void try_prune_one_dentry(struct dentry *dentry) spin_unlock(&dentry->d_lock); return; } + if (dentry->d_op->d_flags & DCACHE_OP_PRUNE) + dentry->d_op->d_prune(dentry); dentry = dentry_kill(dentry, 1); } } @@ -896,6 +898,8 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) /* detach this root from the system */ spin_lock(&dentry->d_lock); + if (dentry->d_op->d_flags & DCACHE_OP_PRUNE) + dentry->d_op->d_prune(dentry); dentry_lru_del(dentry); __d_drop(dentry); spin_unlock(&dentry->d_lock); @@ -912,6 +916,8 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) d_u.d_child) { spin_lock_nested(&loop->d_lock, DENTRY_D_LOCK_NESTED); + if (dentry->d_op->d_flags & DCACHE_OP_PRUNE) + dentry->d_op->d_prune(dentry); dentry_lru_del(loop); __d_drop(loop); spin_unlock(&loop->d_lock); @@ -1375,6 +1381,8 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) dentry->d_flags |= DCACHE_OP_REVALIDATE; if (op->d_delete) dentry->d_flags |= DCACHE_OP_DELETE; + if (op->d_prune) + dentry->d_flags |= DCACHE_OP_PRUNE; } EXPORT_SYMBOL(d_set_d_op); diff --git a/include/linux/dcache.h b/include/linux/dcache.h index f958c19..1e83bd8 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -165,6 +165,7 @@ struct dentry_operations { unsigned int, const char *, const struct qstr *); int (*d_delete)(const struct dentry *); void (*d_release)(struct dentry *); + void (*d_prune)(struct dentry *); void (*d_iput)(struct dentry *, struct inode *); char *(*d_dname)(struct dentry *, char *, int); struct vfsmount *(*d_automount)(struct path *); @@ -219,6 +220,8 @@ struct dentry_operations { #define DCACHE_MANAGED_DENTRY \ (DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT) +#define DCACHE_OP_PRUNE 0x80000 + extern seqlock_t rename_lock; static inline int dname_external(struct dentry *dentry)