From 21cc059eabf1a25136ff162b1d783ca0adee5e39 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 28 Apr 2011 13:22:30 -0700 Subject: [PATCH] mds: fix steal_dentry dir_auth_pins adjustment Pass down the correct value for dir_auth_pins (dh->auth_pins plus the inode's auth_pins, but nothing nested beneath the inode). The CDentry doesn't track dir auth pins independently, and doesn't really need to. Signed-off-by: Sage Weil --- src/mds/CDentry.cc | 8 ++++++++ src/mds/CDentry.h | 1 + src/mds/CDir.cc | 7 +++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index b7dbbc6050078..2e0b40bcc6389 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -346,6 +346,14 @@ CDentry::linkage_t *CDentry::pop_projected_linkage() // ---------------------------- // auth pins +int CDentry::get_num_dir_auth_pins() +{ + assert(!is_projected()); + if (get_linkage()->is_primary()) + return auth_pins + get_linkage()->get_inode()->get_num_auth_pins(); + return auth_pins; +} + bool CDentry::can_auth_pin() { assert(dir); diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index ac7115c8553ef..7046edfc15e84 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -263,6 +263,7 @@ public: bool is_frozen(); bool is_auth_pinned() { return auth_pins || nested_auth_pins; } int get_num_auth_pins() { return auth_pins; } + int get_num_dir_auth_pins(); int get_num_nested_auth_pins() { return nested_auth_pins; } void adjust_nested_anchors(int by); diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index ece3404024b54..efa4962b0eba4 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -732,8 +732,11 @@ void CDir::steal_dentry(CDentry *dn) if (dn->auth_pins || dn->nested_auth_pins) { // use the helpers here to maintain the auth_pin invariants on the dir inode - adjust_nested_auth_pins(dn->nested_auth_pins, dn->auth_pins); - dn->dir->adjust_nested_auth_pins(-dn->nested_auth_pins, -dn->auth_pins); + int ap = dn->get_num_auth_pins() + dn->get_num_nested_auth_pins(); + int dap = dn->get_num_dir_auth_pins(); + assert(dap <= ap); + adjust_nested_auth_pins(ap, dap); + dn->dir->adjust_nested_auth_pins(-ap, -dap); } nested_anchors += dn->nested_anchors; -- 2.39.5