From 57908810d4f58e58b71a050b25fc74671994e4fa Mon Sep 17 00:00:00 2001 From: Vladimir Saveliev Date: Fri, 11 Jun 2010 11:09:40 +0400 Subject: [PATCH] b=21109 mds_lov_read_objids cleanup and conf-sanity tests (1.8) calculate mds->mds_lov_objid_lastidx and mds->mds_lov_objid_lastpage correctly have index strings big enough to store indicies in decimal test to check size of lov_objid and test to check configuraion with big indicies minor compile fix to avoid compile warnings from gcc 4.0.2 i=adilger i=panda i=nathan --- lustre/mds/mds_lov.c | 17 +++++++------- lustre/mgs/mgs_llog.c | 2 +- lustre/tests/conf-sanity.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++ lustre/tests/it_test.c | 3 ++- lustre/utils/loadgen.c | 2 +- 5 files changed, 67 insertions(+), 12 deletions(-) diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index da3c4e0..29419b3 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -387,7 +387,7 @@ static int mds_lov_read_objids(struct obd_device *obd) if (size == 0) RETURN(0); - page = (size/(OBJID_PER_PAGE()*sizeof(obd_id)))+1; + page = (size + MDS_LOV_ALLOC_SIZE - 1) / MDS_LOV_ALLOC_SIZE; CDEBUG(D_INFO, "file size %d pages %d\n", (int)size, page); for (i = 0; i < page; i++) { obd_id *data; @@ -401,23 +401,22 @@ static int mds_lov_read_objids(struct obd_device *obd) data = mds->mds_lov_page_array[i]; rc = fsfilt_read_record(obd, mds->mds_lov_objid_filp, data, - OBJID_PER_PAGE()*sizeof(obd_id), &off); + MDS_LOV_ALLOC_SIZE, &off); if (rc < 0) { CERROR("Error reading objids %d\n", rc); GOTO(out, rc); } + if (off == off_old) /* hole is read */ + off += MDS_LOV_ALLOC_SIZE; count = (off - off_old) / sizeof(obd_id); if (mds_lov_update_from_read(mds, data, count)) { CERROR("Can't update mds data\n"); GOTO(out, rc = -EIO); } - - if (off == off_old) - break; /* eof */ - } - mds->mds_lov_objid_lastpage = i; - mds->mds_lov_objid_lastidx = count; + } + mds->mds_lov_objid_lastpage = page - 1; + mds->mds_lov_objid_lastidx = count - 1; CDEBUG(D_INFO, "Read %u - %u %u objid\n", mds->mds_lov_objid_count, mds->mds_lov_objid_lastpage, mds->mds_lov_objid_lastidx); @@ -440,7 +439,7 @@ int mds_lov_write_objids(struct obd_device *obd) cfs_foreach_bit(mds->mds_lov_page_dirty, i) { obd_id *data = mds->mds_lov_page_array[i]; - unsigned int size = OBJID_PER_PAGE()*sizeof(obd_id); + unsigned int size = MDS_LOV_ALLOC_SIZE; loff_t off = i * size; LASSERT(data != NULL); diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 96071d2..edc3075 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -1183,7 +1183,7 @@ static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *fsdb, { struct llog_handle *llh = NULL; char *nodeuuid, *oscname, *oscuuid, *lovuuid; - char index[5]; + char index[6]; int i, rc; if (mgs_log_is_empty(obd, logname)) { diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 19bd80b..cded53f 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -2192,6 +2192,61 @@ test_50g() { } run_test 50g "deactivated OST should not cause panic=====================" +lov_objid_size() +{ + local max_ost_index=$1 + echo -n $(($max_ost_index * 8 + 8)) +} + +test_55() { + local saved_opts=$OST_MKFS_OPTS + + for i in 0 1023 2048 + do + OST_MKFS_OPTS="$saved_opts --index $i" + reformat + + setup_noconfig + cp /etc/passwd $DIR/1 + stopall + + setup + cp /etc/passwd $DIR/2 + sync + + echo checking size of lov_objid for ost index $i + local file_size=`do_facet mds \ + "$DEBUGFS -R 'stat lov_objid' $MDSDEV 2>/dev/null" | \ + grep ^User | awk '{print $6}'` + if [ "$file_size" != $(lov_objid_size $i) ]; then + error "lov_objid size has to be $(lov_objid_size $i), \ +not $file_size" + else + echo ok, lov_objid size is correct: $file_size + fi + stopall + done + + OST_MKFS_OPTS=$saved_opts + reformat +} +run_test 55 "check lov_objid size" + +test_56() { + add mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $MDSDEV + add ost1 $OST_MKFS_OPTS --index=1000 --reformat `ostdevname 1` + add ost2 $OST_MKFS_OPTS --index=10000 --reformat `ostdevname 2` + + start_mds + start_ost + start_ost2 || error "Unable to start second ost" + mount_client $MOUNT || error "Unable to mount client" + + stopall + reformat +} +run_test 56 "check big indexes" + if ! combined_mgs_mds ; then stop mgs fi diff --git a/lustre/tests/it_test.c b/lustre/tests/it_test.c index 440d647..a97a9bc 100644 --- a/lustre/tests/it_test.c +++ b/lustre/tests/it_test.c @@ -243,8 +243,9 @@ static enum interval_iter sanity_cb(struct interval_node *node, void *args) } if (!has) { - int count = 1; + int count; err: + count = 1; dprintf("node"__S":%llu Child list:\n", node->in_extent.start, node->in_extent.end, diff --git a/lustre/utils/loadgen.c b/lustre/utils/loadgen.c index d11cebe..b555e12 100644 --- a/lustre/utils/loadgen.c +++ b/lustre/utils/loadgen.c @@ -669,7 +669,7 @@ static void *run_one_child(void *threadvp) { struct kid_t *kid; char oname[10], ename[10]; - int thread = (long)threadvp, dev; + int thread = (long)threadvp, dev = 0; int rc = 0, err; if (o_verbose > 2) -- 1.8.3.1