]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Fix truncate_seq/truncate_length initialization.
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 5 Oct 2010 16:25:38 +0000 (09:25 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Tue, 5 Oct 2010 18:20:26 +0000 (11:20 -0700)
Initializing to 0 was causing file_to_extents to get called on every inode
since the MDS initializes truncate_seq to 1 and truncate_length to -1.
This revealed itself as a crash on directory inodes, which have their
layouts zeroed since merging the file_layouts branch.
To make clearer, assert that anything being truncated is a file inode.

src/client/Client.cc
src/client/Client.h

index bd64a6b21be4ac57de66c35e36b0d23766c32410..31750940dc09a3b5bdd469ef40b6cd129d9c7647 100644 (file)
@@ -375,6 +375,7 @@ void Client::update_inode_file_bits(Inode *in,
       in->truncate_size != truncate_size) {
     dout(10) << "truncate_size " << in->truncate_size << " -> "
             << truncate_size << dendl;
+    assert(in->is_file());
     in->truncate_size = truncate_size;
     in->oset.truncate_size = truncate_size;
     if (g_conf.client_oc) { //do actual truncation
index b173a803aed85c111a437c5c4a8422772f0fa289..87acba55f022e603863d4486e9596acbf4ba01e7 100644 (file)
@@ -513,7 +513,7 @@ class Inode {
 
   Inode(vinodeno_t vino, ceph_file_layout *layout) : 
     ino(vino.ino), snapid(vino.snapid),
-    rdev(0), mode(0), uid(0), gid(0), nlink(0), size(0), truncate_seq(0), truncate_size(0),
+    rdev(0), mode(0), uid(0), gid(0), nlink(0), size(0), truncate_seq(1), truncate_size(-1),
     time_warp_seq(0), max_size(0), version(0), xattr_version(0),
     flags(0),
     dir_hashed(false), dir_replicated(false), auth_cap(NULL),