]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: lots of jiffies fixups
authorSage Weil <sage@newdream.net>
Mon, 28 Apr 2008 18:29:06 +0000 (11:29 -0700)
committerSage Weil <sage@newdream.net>
Mon, 28 Apr 2008 18:29:06 +0000 (11:29 -0700)
src/kernel/inode.c
src/kernel/mds_client.c
src/kernel/mon_client.h
src/kernel/super.h

index 3e58b103150da6b6c324ad6bdd22badd2431c32a..157baaf88c20891e69f074321d89fcfc466c92fa 100644 (file)
@@ -347,7 +347,7 @@ int ceph_dentry_lease_valid(struct dentry *dentry)
        int valid = 0;
        spin_lock(&dentry->d_lock);
        di = ceph_dentry(dentry);
-       if (di && time_after(dentry->d_time, jiffies))
+       if (di && time_before(jiffies, dentry->d_time))
                valid = 1;
        spin_unlock(&dentry->d_lock);
        dout(20, "dentry_lease_valid - dentry %p = %d\n", dentry, valid);
@@ -705,7 +705,7 @@ int __ceph_caps_issued(struct ceph_inode_info *ci)
 
        list_for_each(p, &ci->i_caps) {
                cap = list_entry(p, struct ceph_inode_cap, ci_caps);
-               if (time_after(jiffies, cap->session->s_cap_ttl)) {
+               if (time_after_eq(jiffies, cap->session->s_cap_ttl)) {
                        dout(30, "__ceph_caps_issued %p cap %p issued %d "
                             "but STALE\n", &ci->vfs_inode, cap, cap->issued);
                        continue;
@@ -764,10 +764,11 @@ void ceph_cap_delayed_work(struct work_struct *work)
                                                  struct ceph_inode_info,
                                                  i_cap_dwork.work);
        spin_lock(&ci->vfs_inode.i_lock);
-       if (ci->i_hold_caps_until > jiffies) {
+       if (ci->i_hold_caps_until &&
+           time_before(jiffies, ci->i_hold_caps_until)) {
                dout(10, "cap_dwork on %p -- rescheduling\n", &ci->vfs_inode);
-               schedule_delayed_work(&ci->i_cap_dwork,
-                                     ci->i_hold_caps_until - jiffies);
+               schedule_delayed_work(&ci->i_cap_dwork, 
+                                     time_sub(ci->i_hold_caps_until, jiffies));
                spin_unlock(&ci->vfs_inode.i_lock);
        } else {
                dout(10, "cap_dwork on %p\n", &ci->vfs_inode);
@@ -802,12 +803,12 @@ retry:
 
        if (!is_delayed) {
                unsigned long until = round_jiffies(jiffies + HZ * 5);
-               if (until > ci->i_hold_caps_until) {
+               if (time_after(until, ci->i_hold_caps_until)) {
                        ci->i_hold_caps_until = until;
                        dout(10, "hold_caps_until %lu\n", until);
                        cancel_delayed_work(&ci->i_cap_dwork);
                        schedule_delayed_work(&ci->i_cap_dwork,
-                                             until - jiffies);
+                                             time_sub(until, jiffies));
                }
        }
 
@@ -840,7 +841,7 @@ retry:
                if ((cap->issued & ~wanted) == 0)
                        continue;     /* nothing extra, all good */
 
-               if (jiffies < ci->i_hold_caps_until) {
+               if (time_before(jiffies, ci->i_hold_caps_until)) {
                        /* delaying cap release for a bit */
                        dout(30, "delaying cap release\n");
                        continue;
index 53526957130c8ae4c2705de6f94e67d1257d111d..900f888ec15f93b28a3488f1fdb871b07d6e578e 100644 (file)
@@ -545,8 +545,8 @@ static int resume_session(struct ceph_mds_client *mdsc,
        int mds = session->s_mds;
        struct ceph_msg *msg;
 
-       if (time_after(jiffies, session->s_cap_ttl) &&
-           session->s_renew_requested < session->s_cap_ttl)
+       if (time_after_eq(jiffies, session->s_cap_ttl) &&
+           time_before(session->s_renew_requested, session->s_cap_ttl))
                dout(1, "mds%d session caps stale\n", session->s_mds);
 
        dout(10, "resume_session to mds%d\n", mds);
@@ -659,7 +659,7 @@ static void trim_session_leases(struct ceph_mds_session *session)
                ci = list_first_entry(&session->s_inode_leases,
                                      struct ceph_inode_info, i_lease_item);
                spin_lock(&ci->vfs_inode.i_lock);
-               if (ci->i_lease_ttl > jiffies) {
+               if (time_before(jiffies, ci->i_lease_ttl)) {
                        spin_unlock(&ci->vfs_inode.i_lock);
                        break;
                }
@@ -678,7 +678,7 @@ static void trim_session_leases(struct ceph_mds_session *session)
                                      struct ceph_dentry_info, lease_item);
                dentry = di->dentry;
                spin_lock(&dentry->d_lock);
-               if (dentry->d_time > jiffies) {
+               if (time_before(jiffies, dentry->d_time)) {
                        spin_unlock(&dentry->d_lock);
                        break;
                }
@@ -784,7 +784,7 @@ void ceph_mdsc_handle_session(struct ceph_mds_client *mdsc,
        session = __get_session(mdsc, mds);
        down(&session->s_mutex);
 
-       was_stale = time_after(jiffies, session->s_cap_ttl);
+       was_stale = time_after_eq(jiffies, session->s_cap_ttl);
 
        dout(2, "handle_session %p op %d seq %llu\n", session, op, seq);
        switch (op) {
@@ -1502,8 +1502,8 @@ int send_renewcaps(struct ceph_mds_client *mdsc,
 {
        struct ceph_msg *msg;
 
-       if (time_after(jiffies, session->s_cap_ttl) &&
-           session->s_renew_requested < session->s_cap_ttl)
+       if (time_after_eq(jiffies, session->s_cap_ttl) &&
+           time_before_eq(session->s_renew_requested, session->s_cap_ttl))
                dout(1, "mds%d session caps stale\n", session->s_mds);
 
        dout(10, "send_renew_caps to mds%d\n", session->s_mds);
@@ -1741,7 +1741,8 @@ void ceph_mdsc_lease_release(struct ceph_mds_client *mdsc, struct inode *inode,
                mask &= ~CEPH_LOCK_DN;  /* nothing to release */
        ci = ceph_inode(inode);
        ino = ci->i_ceph_ino;
-       if (ci->i_lease_session && time_after(ci->i_lease_ttl, jiffies) &&
+       if (ci->i_lease_session && 
+           time_before(jiffies, ci->i_lease_ttl) &&
            ci->i_lease_session->s_mds >= 0) {
                mds = ci->i_lease_session->s_mds;
                mask &= CEPH_LOCK_DN | ci->i_lease_mask;  /* lease is valid */
@@ -1794,7 +1795,8 @@ void delayed_work(struct work_struct *work)
        struct ceph_mds_client *mdsc =
                container_of(work, struct ceph_mds_client, delayed_work.work);
        int renew_interval = mdsc->mdsmap->m_cap_bit_timeout >> 1;
-       int renew_caps = (jiffies >= HZ*renew_interval + mdsc->last_renew_caps);
+       int renew_caps = time_after_eq(jiffies, HZ*renew_interval + 
+                                      mdsc->last_renew_caps);
 
        dout(10, "delayed_work on %p renew_caps=%d\n", mdsc, renew_caps);
 
index c9284fcc7dc8e3f4eb414344f5f813802205b535..a0ddce5864bdc7232064203830f999465b129339 100644 (file)
@@ -20,7 +20,7 @@ struct ceph_mon_statfs_request {
        int result;
        struct ceph_statfs *buf;
        struct completion completion;
-       u64 last_attempt; /* jiffies */
+       unsigned long last_attempt; /* jiffies */
 };
 
 struct ceph_mon_client {
index 0d29ea534d6699f91726889284ac1d25c80ca9e5..ee7946766183ad1051ee777eda125e45d9a532c5 100644 (file)
@@ -57,6 +57,15 @@ extern int ceph_debug_addr;
                (unsigned int)(((n).sin_addr.s_addr)>>24) & 0xFF,       \
                (unsigned int)(ntohs((n).sin_port))
 
+/*
+ * subtract jiffies
+ */
+static inline unsigned long time_sub(unsigned long a, unsigned long b)
+{
+       BUG_ON(time_after(b, a));
+       return (long)a - (long)b;
+}
+
 /*
  * mount options
  */