Whamcloud - gitweb
LU-2285 osp: Fix last_created updates after orphan cleanups
authorLi Wei <wei.g.li@intel.com>
Mon, 12 Nov 2012 09:50:01 +0000 (17:50 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 28 Nov 2012 18:31:11 +0000 (13:31 -0500)
After an OST orphan cleanup, the OST's last created ID plus one is
stored into opd_pre_last_created.  This is weird and contradicts with
osp_precreate_send() and a few other places, like the following except
from osp_precreate_reserve():

  ...
  precreated = d->opd_pre_last_created - d->opd_pre_used_id;
  if (precreated > d->opd_pre_reserved) {
          d->opd_pre_reserved++;
  ...

The issue is not only about coding style, as suggested by this piece
of debug log dumped by a run of replay-ost-single 2:

  00000004:00080000:0.0:1353838616.328831:0:14474:0:(osp_precreate.c:4
  51:osp_precreate_cleanup_orphans()) lustre-OST0000-osc-MDT0000: Got
  last_id 130 from OST, last_used is 36, pre_used 130
  ...
  00000004:00080000:1.0:1353838616.328935:0:14230:0:(osp_precreate.c:7
  42:osp_precreate_reserve()) lustre-OST0000-osc-MDT0000: precreated 1
  : opd_pre_last_created 131 opd_pre_used_id 130 opd_pre_reserved 0
  00000004:00080000:1.0:1353838616.329173:0:14230:0:(osp_precreate.c:8
  01:osp_precreate_get_id()) lustre-OST0000-osc-MDT0000: Incremented o
  pd_pre_used_id: 131

The first line says that opd_pre_last_created was 131, while on the OST
side the last created ID was 130.  Then, according to the second line, a
request tried to reserve an object and found one.  The last line tells
us that the request consumed 131.  Actually, the OSP at that time hadn't
officially created 131 on the OST yet.

This patch makes sure opd_pre_last_created stores what its name
implies.

Change-Id: I8b94df2c4c702aaac9d68859f59c2d5ec1e8b796
Signed-off-by: Li Wei <wei.g.li@intel.com>
Reviewed-on: http://review.whamcloud.com/4625
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mike Pershin <tappro@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
lustre/osp/osp_precreate.c

index 04f8682..82b822d 100644 (file)
@@ -432,12 +432,12 @@ static int osp_precreate_cleanup_orphans(struct osp_device *d)
                d->opd_pre_grow_count = OST_MIN_PRECREATE +
                                        le64_to_cpu(d->opd_last_used_id) -
                                        body->oa.o_id;
                d->opd_pre_grow_count = OST_MIN_PRECREATE +
                                        le64_to_cpu(d->opd_last_used_id) -
                                        body->oa.o_id;
-               d->opd_pre_last_created = le64_to_cpu(d->opd_last_used_id) + 1;
+               d->opd_pre_last_created = le64_to_cpu(d->opd_last_used_id);
        } else {
                d->opd_pre_grow_count = OST_MIN_PRECREATE;
        } else {
                d->opd_pre_grow_count = OST_MIN_PRECREATE;
-               d->opd_pre_last_created = body->oa.o_id + 1;
+               d->opd_pre_last_created = body->oa.o_id;
        }
        }
-       d->opd_pre_used_id = d->opd_pre_last_created - 1;
+       d->opd_pre_used_id = d->opd_pre_last_created;
        d->opd_pre_grow_slow = 0;
        cfs_spin_unlock(&d->opd_pre_lock);
 
        d->opd_pre_grow_slow = 0;
        cfs_spin_unlock(&d->opd_pre_lock);
 
@@ -722,9 +722,6 @@ int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d)
                        cfs_spin_unlock(&d->opd_pre_lock);
                }
 
                        cfs_spin_unlock(&d->opd_pre_lock);
                }
 
-               /*
-                * we never use the last object in the window
-                */
                cfs_spin_lock(&d->opd_pre_lock);
                precreated = d->opd_pre_last_created - d->opd_pre_used_id;
                if (precreated > d->opd_pre_reserved) {
                cfs_spin_lock(&d->opd_pre_lock);
                precreated = d->opd_pre_last_created - d->opd_pre_used_id;
                if (precreated > d->opd_pre_reserved) {