* Author: Fan Yong <yong.fan@whamcloud.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_MDS
#include <lustre/lustre_idl.h>
ENTRY;
fid_cpu_to_be(oi_fid, fid);
- osd_id_pack(oi_id, id);
+ if (id != NULL)
+ osd_id_pack(oi_id, id);
jh = ldiskfs_journal_start_sb(osd_sb(dev),
osd_dto_credits_noquota[ops]);
if (IS_ERR(jh)) {
sf->sf_items_updated_prior++;
else
sf->sf_items_updated++;
+
+ /* The target has been changed, need to be re-loaded. */
+ lu_object_purge(info->oti_env, osd2lu_dev(dev), fid);
}
GOTO(out, rc);
rc = osd_get_lma(info, inode, &info->oti_obj_dentry, lma);
if (rc == 0) {
if (fid_is_llog(&lma->lma_self_fid) ||
- (!scrub && fid_is_internal(&lma->lma_self_fid)))
+ (!scrub && fid_is_internal(&lma->lma_self_fid)) ||
+ (scrub && (lma->lma_incompat & LMAI_AGENT)))
rc = SCRUB_NEXT_CONTINUE;
else
*fid = lma->lma_self_fid;
brelse(param.bitmap);
RETURN(rc);
}
-
- if (preload && dev->od_otable_it->ooi_stopping) {
- brelse(param.bitmap);
- RETURN(0);
- }
}
next_group:
brelse(param.bitmap);
-
- if (preload && dev->od_otable_it->ooi_stopping)
- RETURN(0);
}
if (*pos > limit)
int rc;
ENTRY;
- cfs_daemonize("OI_scrub");
- rc = lu_env_init(&env, LCT_DT_THREAD);
+ rc = lu_env_init(&env, LCT_LOCAL);
if (rc != 0) {
CERROR("%.16s: OI scrub, fail to init env, rc = %d\n",
LDISKFS_SB(sb)->s_es->s_volume_name, rc);
static int osd_initial_OI_scrub(struct osd_thread_info *info,
struct osd_device *dev)
{
- struct osd_ios_item *item = NULL;
- scandir_t scandir = osd_ios_general_scan;
- filldir_t filldir = osd_ios_root_fill;
- struct dentry *dentry = osd_sb(dev)->s_root;
- int rc;
+ struct osd_ios_item *item = NULL;
+ scandir_t scandir = osd_ios_general_scan;
+ filldir_t filldir = osd_ios_root_fill;
+ struct dentry *dentry = osd_sb(dev)->s_root;
+ const struct osd_lf_map *map = osd_lf_maps;
+ int rc;
ENTRY;
while (1) {
OBD_FREE_PTR(item);
}
- RETURN(rc);
+ if (rc != 0)
+ RETURN(rc);
+
+ /* There maybe the case that the object has been removed, but its OI
+ * mapping is still in the OI file, such as the "CATALOGS" after MDT
+ * file-level backup/restore. So here cleanup the stale OI mappings. */
+ while (map->olm_name != NULL) {
+ struct dentry *child;
+
+ if (fid_is_zero(&map->olm_fid)) {
+ map++;
+ continue;
+ }
+
+ child = osd_ios_lookup_one_len(map->olm_name,
+ osd_sb(dev)->s_root,
+ strlen(map->olm_name));
+ if (!IS_ERR(child))
+ dput(child);
+ else if (PTR_ERR(child) == -ENOENT)
+ osd_scrub_refresh_mapping(info, dev, &map->olm_fid,
+ NULL, DTO_INDEX_DELETE);
+ map++;
+ }
+
+ RETURN(0);
}
char *osd_lf_fid2name(const struct lu_fid *fid)
scrub->os_start_flags = flags;
thread_set_flags(thread, 0);
- rc = cfs_create_thread(osd_scrub_main, dev, 0);
- if (rc < 0) {
+ rc = PTR_ERR(kthread_run(osd_scrub_main, dev, "OI_scrub"));
+ if (IS_ERR_VALUE(rc)) {
CERROR("%.16s: cannot start iteration thread, rc = %d\n",
LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name, rc);
RETURN(rc);
rc = osd_scrub_start(dev);
}
+ /* it is possible that dcache entries may keep objects after they are
+ * deleted by OSD. While it looks safe this can cause object data to
+ * stay until umount causing failures in tests calculating free space,
+ * e.g. replay-ost-single. Since those dcache entries are not used
+ * anymore let's just free them after use here */
+ shrink_dcache_sb(sb);
+
RETURN(rc);
}
dev->od_otable_it = it;
it->ooi_dev = dev;
- it->ooi_pid = cfs_curproc_pid();
it->ooi_cache.ooc_consumer_idx = -1;
if (flags & DOIF_OUTUSED)
it->ooi_used_outside = 1;
return 0;
}
-/**
- * It is hack here:
- *
- * Sometimes the otable-based iteration driver (LFSCK) may be blocked in OSD
- * layer when someone wants to stop/pause the iteration. Under such case, we
- * need some mechanism to notify the event and wakeup the blocker.
- */
static void osd_otable_it_put(const struct lu_env *env, struct dt_it *di)
{
- struct osd_otable_it *it = (struct osd_otable_it *)di;
- struct osd_device *dev = it->ooi_dev;
-
- /* od_otable_mutex: prevent curcurrent init/fini */
- mutex_lock(&dev->od_otable_mutex);
- if (it->ooi_pid == cfs_curproc_pid()) {
- dev->od_scrub.os_paused = 1;
- } else {
- struct ptlrpc_thread *thread = &dev->od_scrub.os_thread;
-
- it->ooi_stopping = 1;
- if (it->ooi_waiting)
- cfs_waitq_broadcast(&thread->t_ctl_waitq);
- }
- mutex_unlock(&dev->od_otable_mutex);
}
static inline int
{
spin_lock(&scrub->os_lock);
if (it->ooi_cache.ooc_pos_preload < scrub->os_pos_current ||
- scrub->os_waiting || it->ooi_stopping ||
+ scrub->os_waiting ||
!thread_is_running(&scrub->os_thread))
it->ooi_waiting = 0;
else
if (!thread_is_running(thread) && !it->ooi_used_outside)
RETURN(1);
- if (it->ooi_stopping)
- RETURN(0);
-
rc = osd_otable_it_preload(env, it);
if (rc >= 0)
goto again;