From patchwork Thu Aug 16 05:34:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1329821 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6F06A40210 for ; Thu, 16 Aug 2012 05:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752040Ab2HPFfK (ORCPT ); Thu, 16 Aug 2012 01:35:10 -0400 Received: from lsd-gw.ic.unicamp.br ([143.106.7.165]:41484 "EHLO boneca.lsd.ic.unicamp.br" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751457Ab2HPFfJ (ORCPT ); Thu, 16 Aug 2012 01:35:09 -0400 Received: from freie (gw-to-emilia.oliva.athome.lsd.ic.unicamp.br [172.31.160.17] (may be forged)) by boneca.lsd.ic.unicamp.br (8.14.5/8.14.5) with ESMTP id q7G5Z4VT018564 for ; Thu, 16 Aug 2012 02:35:04 -0300 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie (8.14.5/8.14.5) with ESMTP id q7G5Z3Pf026892 for ; Thu, 16 Aug 2012 02:35:03 -0300 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q7G5Z24O016695; Thu, 16 Aug 2012 02:35:02 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id q7G5Yvuh016693; Thu, 16 Aug 2012 02:34:57 -0300 X-Authentication-Warning: livre.localdomain: aoliva set sender to oliva@lsd.ic.unicamp.br using -f From: Alexandre Oliva To: ceph-devel@vger.kernel.org Subject: Preserve dir default_file_layout in encoded inode Organization: Free thinker, not speaking for University of Campinas Date: Thu, 16 Aug 2012 02:34:57 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Store dir layouts not only in the journal, but also in inode information for the directory, so that they aren't dropped on the floor when dirs are evicted from the MDS cache and dropped from the journal. Also restore dir layouts when fetching dirs back into the MDS cache. This is supposed to fix for bug 1435, except that it doesn't look like a layout change to a directory will trigger a commit of the new layout if the directory is not otherwise modified before the change is evicted from the cache and the journal. This can be sorted out in a separate patch. Signed-off-by: Alexandre Oliva --- src/mds/CDir.cc | 16 +++++++++++++++- src/mds/CInode.h | 9 +++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 6761c6f..df19252 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -1552,8 +1552,16 @@ void CDir::_fetched(bufferlist &bl, const string& want_dn) << " already exists at " << inopath << "\n"; continue; } else { + ceph_file_layout unset_fl = ceph_file_layout(), *fl; + + if (inode.is_dir () + && memcmp (&inode.layout, &unset_fl, sizeof (unset_fl)) != 0) + fl = &inode.layout; + else + fl = NULL; + // inode - in = new CInode(cache, true, first, last); + in = new CInode(cache, true, first, last, fl); in->inode = inode; // symlink? @@ -1845,6 +1853,12 @@ void CDir::_encode_dentry(CDentry *dn, bufferlist& bl, dout(14) << " pos " << bl.length() << " dn '" << dn->name << "' inode " << *in << dendl; + ceph_file_layout *fl = in->get_projected_dir_layout (); + if (fl) + in->inode.layout = *fl; + else + memset (&in->inode.layout, 0, sizeof (in->inode.layout)); + // marker, name, inode, [symlink string] bl.append('I'); // inode ::encode(in->inode, bl); diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 57c76c4..8b42f6f 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -71,6 +71,9 @@ struct default_file_layout { ceph_file_layout layout; + default_file_layout() {}; + default_file_layout(ceph_file_layout l) : layout(l) {}; + void encode(bufferlist &bl) const { __u8 struct_v = 1; ::encode(struct_v, bl); @@ -458,12 +461,13 @@ private: public: // --------------------------- - CInode(MDCache *c, bool auth=true, snapid_t f=2, snapid_t l=CEPH_NOSNAP) : + CInode(MDCache *c, bool auth=true, snapid_t f=2, snapid_t l=CEPH_NOSNAP, + ceph_file_layout *dl = NULL) : mdcache(c), snaprealm(0), containing_realm(0), first(f), last(l), last_journaled(0), //last_open_journaled(0), - default_layout(NULL), + default_layout(dl ? new default_file_layout (*dl) : NULL), //hack_accessed(true), stickydir_ref(0), parent(0), @@ -498,6 +502,7 @@ private: g_num_inos++; close_dirfrags(); close_snaprealm(); + delete default_layout; }