X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_scrub.c;h=352cdb82730cf109a976d2c86c9060e818803b31;hb=773c6672533f680f51c2632cefb4249a6190d269;hp=e24e54af438901befd608c199eae99f9dd6f6bdf;hpb=7cecfcffae9737f929a2cbc8067e093a4f85c3ba;p=fs%2Flustre-release.git diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index e24e54a..352cdb8 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -157,6 +157,8 @@ void osd_scrub_file_reset(struct osd_scrub *scrub, __u8 *uuid, __u64 flags) sf->sf_items_updated = 0; sf->sf_items_failed = 0; sf->sf_items_updated_prior = 0; + sf->sf_items_noscrub = 0; + sf->sf_items_igif = 0; } static int osd_scrub_file_load(struct osd_scrub *scrub) @@ -214,7 +216,7 @@ int osd_scrub_file_store(struct osd_scrub *scrub) osd_scrub_file_to_le(&scrub->os_file_disk, &scrub->os_file); rc = osd_ldiskfs_write_record(scrub->os_inode, &scrub->os_file_disk, - len, &pos, jh); + len, 0, &pos, jh); ldiskfs_journal_stop(jh); if (rc != 0) CERROR("%.16s: fail to store scrub file, expected = %d, " @@ -500,6 +502,8 @@ static void osd_scrub_post(struct osd_scrub *scrub, int result) #define SCRUB_NEXT_WAIT 4 /* wait for free cache slot */ #define SCRUB_NEXT_CRASH 5 /* simulate system crash during OI scrub */ #define SCRUB_NEXT_FATAL 6 /* simulate failure during OI scrub */ +#define SCRUB_NEXT_NOSCRUB 7 /* new created object, no scrub on it */ +#define SCRUB_NEXT_IGIF 8 /* IGIF object */ struct osd_iit_param { struct super_block *sb; @@ -624,8 +628,14 @@ static int osd_scrub_next(struct osd_thread_info *info, struct osd_device *dev, if (rc != 0) return rc; - if (!fid_is_norm(fid) || inode->i_state & I_LUSTRE_NOSCRUB) - rc = SCRUB_NEXT_CONTINUE; + if (inode->i_state & I_LUSTRE_NOSCRUB) { + /* Only skip it for the first OI scrub accessing. */ + inode->i_state &= ~I_LUSTRE_NOSCRUB; + rc = SCRUB_NEXT_NOSCRUB; + } else if (!fid_is_norm(fid)) { + rc = SCRUB_NEXT_IGIF; + } + iput(inode); return rc; } @@ -668,6 +678,8 @@ static int osd_scrub_exec(struct osd_thread_info *info, struct osd_device *dev, { struct l_wait_info lwi = { 0 }; struct osd_scrub *scrub = &dev->od_scrub; + struct scrub_file *sf = &scrub->os_file; + __u64 *items = NULL; struct ptlrpc_thread *thread = &scrub->os_thread; struct osd_otable_it *it = dev->od_otable_it; struct osd_otable_cache *ooc = it ? &it->ooi_cache : NULL; @@ -677,6 +689,20 @@ static int osd_scrub_exec(struct osd_thread_info *info, struct osd_device *dev, goto next; case SCRUB_NEXT_WAIT: goto wait; + case SCRUB_NEXT_NOSCRUB: + items = &sf->sf_items_noscrub; + break; + case SCRUB_NEXT_IGIF: + items = &sf->sf_items_igif; + break; + } + + if (items != NULL) { + cfs_down_write(&scrub->os_rwsem); + scrub->os_new_checked++; + (*items)++; + cfs_up_write(&scrub->os_rwsem); + goto next; } LASSERTF(rc <= 0, "unexpected rc = %d\n", rc); @@ -924,6 +950,9 @@ again: } cfs_spin_unlock(&scrub->os_lock); + if (scrub->os_file.sf_status == SS_COMPLETED) + flags |= SS_RESET; + scrub->os_start_flags = flags; thread_set_flags(thread, 0); rc = cfs_create_thread(osd_scrub_main, dev, 0); @@ -942,16 +971,12 @@ again: int osd_scrub_start(struct osd_device *dev) { - __u32 flags = SS_AUTO; - int rc; + int rc; ENTRY; - if (dev->od_scrub.os_file.sf_status == SS_COMPLETED) - flags |= SS_RESET; - /* od_otable_mutex: prevent curcurrent start/stop */ cfs_mutex_lock(&dev->od_otable_mutex); - rc = do_osd_scrub_start(dev, flags); + rc = do_osd_scrub_start(dev, SS_AUTO); cfs_mutex_unlock(&dev->od_otable_mutex); RETURN(rc == -EALREADY ? 0 : rc); @@ -1016,8 +1041,6 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev) cfs_init_rwsem(&scrub->os_rwsem); cfs_spin_lock_init(&scrub->os_lock); CFS_INIT_LIST_HEAD(&scrub->os_inconsistent_items); - if (get_mount_flags(dev->od_mount->lmi_sb) & LMD_FLG_NOSCRUB) - scrub->os_no_scrub = 1; push_ctxt(&saved, ctxt, NULL); filp = filp_open(osd_scrub_name, O_RDWR | O_CREAT, 0644); @@ -1081,7 +1104,7 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev) } } - if (rc == 0 && !scrub->os_no_scrub && + if (rc == 0 && !dev->od_noscrub && ((sf->sf_status == SS_PAUSED) || (sf->sf_status == SS_CRASHED && sf->sf_flags & (SF_RECREATED | SF_INCONSISTENT | SF_AUTO)) || @@ -1569,9 +1592,12 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) "updated: "LPU64"\n" "failed: "LPU64"\n" "prior_updated: "LPU64"\n" + "noscrub: "LPU64"\n" + "igif: "LPU64"\n" "success_count: %u\n", checked, sf->sf_items_updated, sf->sf_items_failed, - sf->sf_items_updated_prior, sf->sf_success_count); + sf->sf_items_updated_prior, sf->sf_items_noscrub, + sf->sf_items_igif, sf->sf_success_count); if (rc <= 0) goto out;