From patchwork Tue Mar 22 00:48:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sage Weil X-Patchwork-Id: 651531 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 p2M0hGUA022447 for ; Tue, 22 Mar 2011 00:43:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754792Ab1CVAnO (ORCPT ); Mon, 21 Mar 2011 20:43:14 -0400 Received: from cobra.newdream.net ([66.33.216.30]:54378 "EHLO cobra.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750894Ab1CVAnN (ORCPT ); Mon, 21 Mar 2011 20:43:13 -0400 Received: from localhost.localdomain (ip-66-33-206-8.dreamhost.com [66.33.206.8]) by cobra.newdream.net (Postfix) with ESMTPA id 51190BC931; Mon, 21 Mar 2011 17:45:52 -0700 (PDT) From: Sage Weil To: linux-fsdevel@vger.kernel.org, viro@ZenIV.linux.org.uk Cc: linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, Sage Weil Subject: [PATCH 2/4] ceph: clear parent D_COMPLETE flag when on dentry prune Date: Mon, 21 Mar 2011 17:48:19 -0700 Message-Id: <1300754901-4284-3-git-send-email-sage@newdream.net> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1300754901-4284-1-git-send-email-sage@newdream.net> References: <1300754901-4284-1-git-send-email-sage@newdream.net> 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]); Tue, 22 Mar 2011 00:43:16 +0000 (UTC) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 1a867a3..e2005fa 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1053,7 +1053,33 @@ static int ceph_snapdir_d_revalidate(struct dentry *dentry, return 1; } +/* + * When the VFS prunes a dentry from the cache, we need to clear the + * complete flag on the parent directory. + * + * Called under dentry->d_lock. + */ +static void ceph_d_prune(struct dentry *dentry) +{ + struct ceph_dentry_info *di; + + dout("d_release %p\n", dentry); + + /* do we have a valid parent? */ + if (!dentry->d_parent || IS_ROOT(dentry)) + return; + + /* if we are not hashed, we don't affect D_COMPLETE */ + if (d_unhashed(dentry)) + return; + /* + * we hold d_lock, so d_parent is stable, and d_fsdata is never + * cleared until d_release + */ + di = ceph_dentry(dentry->d_parent); + clear_bit(CEPH_D_COMPLETE, &di->flags); +} /* * read() on a dir. This weird interface hack only works if mounted @@ -1259,6 +1285,7 @@ const struct inode_operations ceph_dir_iops = { const struct dentry_operations ceph_dentry_ops = { .d_revalidate = ceph_d_revalidate, .d_release = ceph_d_release, + .d_prune = ceph_d_prune, }; const struct dentry_operations ceph_snapdir_dentry_ops = { @@ -1268,4 +1295,5 @@ const struct dentry_operations ceph_snapdir_dentry_ops = { const struct dentry_operations ceph_snap_dentry_ops = { .d_release = ceph_d_release, + .d_prune = ceph_d_prune, }; diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 619fe71..b6bf098 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -201,6 +201,7 @@ struct ceph_inode_xattr { * Ceph dentry state */ struct ceph_dentry_info { + unsigned long flags; struct ceph_mds_session *lease_session; u32 lease_gen, lease_shared_gen; u32 lease_seq; @@ -211,6 +212,18 @@ struct ceph_dentry_info { u64 offset; }; +/* + * dentry flags + * + * The locking for D_COMPLETE is a bit odd: + * - we can clear it at almost any time (see ceph_d_prune) + * - it is only meaningful if: + * - we hold dir inode i_lock + * - we hold dir FILE_SHARED caps + * - the dentry D_COMPLETE is set + */ +#define CEPH_D_COMPLETE 1 /* if set, d_u.d_subdirs is complete directory */ + struct ceph_inode_xattrs_info { /* * (still encoded) xattr blob. we avoid the overhead of parsing