From 4bc6291fc8a7494e8286151ec3b0713e57ce258c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 17 Apr 2009 12:26:44 -0700 Subject: [PATCH] kclient: break I_NODELAY into NODELAY and FLUSH FLUSH indicates the inode should be flushed asap. That is, we should send a cap message with the dirty metadata. It's set by write_inode. NODELAY means we shouldn't delay our cap/wanted release when we do send a message. It's set for unlinked files. --- src/kernel/caps.c | 21 ++++++++++----------- src/kernel/super.h | 3 ++- src/messages/MClientRequest.h | 8 ++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/kernel/caps.c b/src/kernel/caps.c index 39406b4c84edc..412c025509415 100644 --- a/src/kernel/caps.c +++ b/src/kernel/caps.c @@ -334,18 +334,13 @@ static void __insert_cap_node(struct ceph_inode_info *ci, } /* - * Set cap hold timeouts, unless already I_NODELAY. + * (re)set cap hold timeouts. */ static void __cap_set_timeouts(struct ceph_mds_client *mdsc, struct ceph_inode_info *ci) { struct ceph_mount_args *ma = &mdsc->client->mount_args; - if (ci->i_ceph_flags & CEPH_I_NODELAY) { - dout(10, "__cap_set_timeouts %p I_NODELAY\n", &ci->vfs_inode); - return; - } - ci->i_hold_caps_min = round_jiffies(jiffies + ma->caps_wanted_delay_min * HZ); ci->i_hold_caps_max = round_jiffies(jiffies + @@ -358,6 +353,8 @@ static void __cap_set_timeouts(struct ceph_mds_client *mdsc, * an inode was queued but with i_hold_caps_max=0, meaning it was * queued for immediate flush, don't reset the timeouts. * + * If I_FLUSH is set, leave the inode at the front of the list. + * * Caller holds i_lock * -> we take mdsc->cap_delay_lock */ @@ -369,7 +366,7 @@ static void __cap_delay_requeue(struct ceph_mds_client *mdsc, if (!mdsc->stopping) { spin_lock(&mdsc->cap_delay_lock); if (!list_empty(&ci->i_cap_delay_list)) { - if (ci->i_ceph_flags & CEPH_I_NODELAY) + if (ci->i_ceph_flags & CEPH_I_FLUSH) goto no_change; list_del_init(&ci->i_cap_delay_list); } @@ -380,14 +377,16 @@ static void __cap_delay_requeue(struct ceph_mds_client *mdsc, } /* - * Queue an inode for immediate writeback. + * Queue an inode for immediate writeback. Mark inode with I_FLUSH, + * indicating we should send a cap message to flush dirty metadata + * asap. */ static void __cap_delay_requeue_front(struct ceph_mds_client *mdsc, struct ceph_inode_info *ci) { dout(10, "__cap_delay_requeue_front %p\n", &ci->vfs_inode); spin_lock(&mdsc->cap_delay_lock); - ci->i_ceph_flags |= CEPH_I_NODELAY; + ci->i_ceph_flags |= CEPH_I_FLUSH; if (!list_empty(&ci->i_cap_delay_list)) list_del_init(&ci->i_cap_delay_list); list_add(&ci->i_cap_delay_list, &mdsc->cap_delay_list); @@ -875,7 +874,7 @@ static void __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, want |= cap->mds_wanted; retain |= cap->issued; } - ci->i_ceph_flags &= ~CEPH_I_NODELAY; + ci->i_ceph_flags &= ~(CEPH_I_NODELAY | CEPH_I_FLUSH); cap->issued &= retain; /* drop bits we don't want */ if (cap->implemented & ~cap->issued) { @@ -2229,7 +2228,7 @@ void ceph_check_delayed_caps(struct ceph_mds_client *mdsc) ci = list_first_entry(&mdsc->cap_delay_list, struct ceph_inode_info, i_cap_delay_list); - if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 && + if ((ci->i_ceph_flags & CEPH_I_FLUSH) == 0 && time_before(jiffies, ci->i_hold_caps_max)) break; list_del_init(&ci->i_cap_delay_list); diff --git a/src/kernel/super.h b/src/kernel/super.h index 61d0da954ea21..c827764dd1e32 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -274,7 +274,8 @@ struct ceph_inode_xattrs_info { */ #define CEPH_I_COMPLETE 1 /* we have complete directory cached */ #define CEPH_I_READDIR 2 /* no dentries trimmed since readdir start */ -#define CEPH_I_NODELAY 4 /* do not delay flush caps */ +#define CEPH_I_NODELAY 4 /* do not delay cap release */ +#define CEPH_I_FLUSH 8 /* do not delay cap send */ struct ceph_inode_info { struct ceph_vino i_vino; /* ceph ino + snap */ diff --git a/src/messages/MClientRequest.h b/src/messages/MClientRequest.h index 02020e2c03629..ba825a8a2ce13 100644 --- a/src/messages/MClientRequest.h +++ b/src/messages/MClientRequest.h @@ -170,6 +170,14 @@ public: out << "client_request(" << get_orig_source() << ":" << get_tid() << " " << ceph_mds_op_name(get_op()); + if (head.op == CEPH_MDS_OP_SETATTR) { + if (head.args.setattr.mask & CEPH_SETATTR_MODE) out << " mode"; + if (head.args.setattr.mask & CEPH_SETATTR_UID) out << " uid"; + if (head.args.setattr.mask & CEPH_SETATTR_GID) out << " gid"; + if (head.args.setattr.mask & CEPH_SETATTR_SIZE) out << " size"; + if (head.args.setattr.mask & CEPH_SETATTR_MTIME) out << " mtime"; + if (head.args.setattr.mask & CEPH_SETATTR_ATIME) out << " atime"; + } //if (!get_filepath().empty()) out << " " << get_filepath(); if (!get_filepath2().empty()) -- 2.39.5