Skip to contentSkip to conversation

mds: fix setting/removing xattrs on root

PATCH New Kuan Kai Chiu 2 participants 4 messages Apr 15, 2013 – Apr 18, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mds: fix setting/removing xattrs on root

MDS crashes while journaling dirty root inode in handle_client_setxattr and handle_client_removexattr. We should use journal_dirty_inode to safely log root inode here.

Kuan Kai Chiu (1):
mds: fix setting/removing xattrs on root

 src/mds/Server.cc |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 mds: fix setting/removing xattrs on root

MDS crashes while journaling dirty root inode in handle_client_setxattr and handle_client_removexattr. We should use journal_dirty_inode to safely log root inode here.

---
 src/mds/Server.cc |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/mds/Server.cc +2 -4
index 11ab834..1e62dd2 100644
@@ -3907,8 +3907,7 @@ void Server::handle_client_setxattr(MDRequest *mdr)
   mdlog->start_entry(le);
   le->metablob.add_client_req(req->get_reqid(), req->get_oldest_client_tid());
   mdcache->predirty_journal_parents(mdr, &le->metablob, cur, 0, PREDIRTY_PRIMARY, false);
-  mdcache->journal_cow_inode(mdr, &le->metablob, cur);
-  le->metablob.add_primary_dentry(cur->get_projected_parent_dn(), true, cur);
+  mdcache->journal_dirty_inode(mdr, &le->metablob, cur);
 
   journal_and_reply(mdr, cur, 0, le, new C_MDS_inode_update_finish(mds, mdr, cur));
 }
@@ -3964,8 +3963,7 @@ void Server::handle_client_removexattr(MDRequest *mdr)
   mdlog->start_entry(le);
   le->metablob.add_client_req(req->get_reqid(), req->get_oldest_client_tid());
   mdcache->predirty_journal_parents(mdr, &le->metablob, cur, 0, PREDIRTY_PRIMARY, false);
-  mdcache->journal_cow_inode(mdr, &le->metablob, cur);
-  le->metablob.add_primary_dentry(cur->get_projected_parent_dn(), true, cur);
+  mdcache->journal_dirty_inode(mdr, &le->metablob, cur);
 
   journal_and_reply(mdr, cur, 0, le, new C_MDS_inode_update_finish(mds, mdr, cur));
 }
Signature · 1 line
1.7.9.5
#2 lore raw
Quoted 22 lines · Kuan Kai Chiu

MDS crashes while journaling dirty root inode in handle_client_setxattr and handle_client_removexattr. We should use journal_dirty_inode to safely log root inode here.

---
 src/mds/Server.cc |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/mds/Server.cc +1 -2
index 11ab834..1e62dd2 100644
@@ -3907,8 +3907,7 @@ void Server::handle_client_setxattr(MDRequest *mdr)
   mdlog->start_entry(le);
   le->metablob.add_client_req(req->get_reqid(), req->get_oldest_client_tid());
   mdcache->predirty_journal_parents(mdr, &le->metablob, cur, 0, PREDIRTY_PRIMARY, false);
-  mdcache->journal_cow_inode(mdr, &le->metablob, cur);
-  le->metablob.add_primary_dentry(cur->get_projected_parent_dn(), true, cur);
+  mdcache->journal_dirty_inode(mdr, &le->metablob, cur);
 
   journal_and_reply(mdr, cur, 0, le, new C_MDS_inode_update_finish(mds, mdr, cur));
 }

src/mds/Server.cc void Server::handle_client_removexattr(MDRequest *mdr) · line 3969

Quoted 9 lines
src/mds/Server.cc +1 -2
@@ -3964,8 +3963,7 @@ void Server::handle_client_removexattr(MDRequest *mdr)
   mdlog->start_entry(le);
   le->metablob.add_client_req(req->get_reqid(), req->get_oldest_client_tid());
   mdcache->predirty_journal_parents(mdr, &le->metablob, cur, 0, PREDIRTY_PRIMARY, false);
-  mdcache->journal_cow_inode(mdr, &le->metablob, cur);
-  le->metablob.add_primary_dentry(cur->get_projected_parent_dn(), true, cur);
+  mdcache->journal_dirty_inode(mdr, &le->metablob, cur);
 
   journal_and_reply(mdr, cur, 0, le, new C_MDS_inode_update_finish(mds, mdr, cur));
 }

This is fine as far as it goes, but we'll need your sign-off for us to incorporate it into the codebase. Also, have you run any tests with it? The reason I ask is that when I apply this patch, set an xattr on the root inode, and then restart the MDS and client, there are no xattrs on the root any more. I think this should fix that, but there may be other such issues:

src/mds/events/EMetaBlob.h +1 -1
index 7065460..439bd78 100644
@@ -468,7 +468,7 @@ private:
 
     if (!pi) pi = in->get_projected_inode();
     if (!pdft) pdft = &in->dirfragtree;
-    if (!px) px = &in->xattrs;
+    if (!px) px = in->get_projected_xattrs();
 
     bufferlist snapbl;
     if (psnapbl)

You've fallen victim to this new setup, incidentally — in the past the root inode wasn't allowed to get any of these modifications because it's not quite real in the way the rest of them are. We opened that up when we made the virtual xattr interface, but we weren't very careful about it so apparently we missed some side effects.
-Greg
Software Engineer #42 @ http://inktank.com | http://ceph.com
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

I didn't notice the bug. Guessing it was hidden because CephFS had been accessed by other daemons in my test environment. Thank you for the hint!

The signed-off patches are resent, also including your fix.

Quoted 53 lines · Gregory Farnum
Quoted 22 lines · Kuan Kai Chiu

MDS crashes while journaling dirty root inode in handle_client_setxattr and handle_client_removexattr. We should use journal_dirty_inode to safely log root inode here.

---
 src/mds/Server.cc |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/mds/Server.cc +1 -2
index 11ab834..1e62dd2 100644
@@ -3907,8 +3907,7 @@ void Server::handle_client_setxattr(MDRequest *mdr)
   mdlog->start_entry(le);
   le->metablob.add_client_req(req->get_reqid(), req->get_oldest_client_tid());
   mdcache->predirty_journal_parents(mdr, &le->metablob, cur, 0, PREDIRTY_PRIMARY, false);
-  mdcache->journal_cow_inode(mdr, &le->metablob, cur);
-  le->metablob.add_primary_dentry(cur->get_projected_parent_dn(), true, cur);
+  mdcache->journal_dirty_inode(mdr, &le->metablob, cur);
 
   journal_and_reply(mdr, cur, 0, le, new C_MDS_inode_update_finish(mds, mdr, cur));
 }

src/mds/Server.cc void Server::handle_client_removexattr(MDRequest *mdr) · line 3969

Quoted 9 lines
src/mds/Server.cc +1 -2
@@ -3964,8 +3963,7 @@ void Server::handle_client_removexattr(MDRequest *mdr)
   mdlog->start_entry(le);
   le->metablob.add_client_req(req->get_reqid(), req->get_oldest_client_tid());
   mdcache->predirty_journal_parents(mdr, &le->metablob, cur, 0, PREDIRTY_PRIMARY, false);
-  mdcache->journal_cow_inode(mdr, &le->metablob, cur);
-  le->metablob.add_primary_dentry(cur->get_projected_parent_dn(), true, cur);
+  mdcache->journal_dirty_inode(mdr, &le->metablob, cur);
 
   journal_and_reply(mdr, cur, 0, le, new C_MDS_inode_update_finish(mds, mdr, cur));
 }

This is fine as far as it goes, but we'll need your sign-off for us to incorporate it into the codebase. Also, have you run any tests with it? The reason I ask is that when I apply this patch, set an xattr on the root inode, and then restart the MDS and client, there are no xattrs on the root any more. I think this should fix that, but there may be other such issues:

src/mds/events/EMetaBlob.h +1 -1
index 7065460..439bd78 100644
@@ -468,7 +468,7 @@ private:
 
     if (!pi) pi = in->get_projected_inode();
     if (!pdft) pdft = &in->dirfragtree;
-    if (!px) px = &in->xattrs;
+    if (!px) px = in->get_projected_xattrs();
 
     bufferlist snapbl;
     if (psnapbl)
Quoted 7 lines

You've fallen victim to this new setup, incidentally — in the past the root inode wasn't allowed to get any of these modifications because it's not quite real in the way the rest of them are. We opened that up when we made the virtual xattr interface, but we weren't very careful about it so apparently we missed some side effects.
-Greg
Software Engineer #42 @ http://inktank.com | http://ceph.com

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html