const struct lu_fid *fid,
const struct osd_inode_id *id,
int ops, bool force,
- enum oi_check_flags flags)
+ enum oi_check_flags flags, bool *exist)
{
handle_t *th;
int rc;
rc = PTR_ERR(th);
CDEBUG(D_LFSCK, "%s: fail to start trans for scrub op %d "
DFID" => %u/%u: rc = %d\n", osd_name(dev), ops,
- PFID(fid), id->oii_ino, id->oii_gen, rc);
+ PFID(fid), id ? id->oii_ino : -1, id ? id->oii_gen : -1,
+ rc);
RETURN(rc);
}
}
break;
case DTO_INDEX_INSERT:
- rc = osd_oi_insert(info, dev, fid, id, th, flags);
+ rc = osd_oi_insert(info, dev, fid, id, th, flags, exist);
if (unlikely(rc == -EEXIST)) {
rc = 1;
/* XXX: There are trouble things when adding OI
struct osd_inconsistent_item *oii = NULL;
struct inode *inode = NULL;
int ops = DTO_INDEX_UPDATE;
- int idx;
int rc;
bool converted = false;
+ bool exist = false;
ENTRY;
down_write(&scrub->os_rwsem);
if (!scrub->os_partial_scan)
scrub->os_full_speed = 1;
- idx = osd_oi_fid2idx(dev, fid);
switch (val) {
case SCRUB_NEXT_NOLMA:
sf->sf_flags |= SF_UPGRADE;
case SCRUB_NEXT_OSTOBJ_OLD:
break;
default:
- sf->sf_flags |= SF_RECREATED;
- if (unlikely(!ldiskfs_test_bit(idx, sf->sf_oi_bitmap)))
- ldiskfs_set_bit(idx, sf->sf_oi_bitmap);
break;
}
} else if (osd_id_eq(lid, lid2)) {
rc = osd_scrub_refresh_mapping(info, dev, fid, lid, ops, false,
(val == SCRUB_NEXT_OSTOBJ ||
- val == SCRUB_NEXT_OSTOBJ_OLD) ? OI_KNOWN_ON_OST : 0);
+ val == SCRUB_NEXT_OSTOBJ_OLD) ? OI_KNOWN_ON_OST : 0,
+ &exist);
if (rc == 0) {
if (scrub->os_in_prior)
sf->sf_items_updated_prior++;
else
sf->sf_items_updated++;
+
+ if (ops == DTO_INDEX_INSERT && val == 0 && !exist) {
+ int idx = osd_oi_fid2idx(dev, fid);
+
+ sf->sf_flags |= SF_RECREATED;
+ if (unlikely(!ldiskfs_test_bit(idx, sf->sf_oi_bitmap)))
+ ldiskfs_set_bit(idx, sf->sf_oi_bitmap);
+ }
}
GOTO(out, rc);
DTO_INDEX_DELETE, false,
(val == SCRUB_NEXT_OSTOBJ ||
val == SCRUB_NEXT_OSTOBJ_OLD) ?
- OI_KNOWN_ON_OST : 0);
+ OI_KNOWN_ON_OST : 0, NULL);
up_write(&scrub->os_rwsem);
if (inode != NULL && !IS_ERR(inode))
iput(inode);
if (oii != NULL) {
- LASSERT(list_empty(&oii->oii_list));
+ spin_lock(&scrub->os_lock);
+ if (likely(!list_empty(&oii->oii_list)))
+ list_del(&oii->oii_list);
+ spin_unlock(&scrub->os_lock);
OBD_FREE_PTR(oii);
}
oii = list_entry(scrub->os_inconsistent_items.next,
struct osd_inconsistent_item, oii_list);
- list_del_init(&oii->oii_list);
spin_unlock(&scrub->os_lock);
*oic = &oii->oii_cache;
sf->sf_status = SS_SCANNING;
}
- if (flags & SS_AUTO_FULL) {
- sf->sf_flags |= SF_AUTO;
- scrub->os_full_speed = 1;
- }
-
if (sf->sf_flags & (SF_RECREATED | SF_INCONSISTENT | SF_UPGRADE))
scrub->os_full_speed = 1;
else
scrub->os_full_speed = 0;
+ if (flags & SS_AUTO_FULL) {
+ sf->sf_flags |= SF_AUTO;
+ scrub->os_full_speed = 1;
+ }
+
scrub->os_new_checked = 0;
if (sf->sf_pos_last_checkpoint != 0)
sf->sf_pos_latest_start = sf->sf_pos_last_checkpoint + 1;
*count < max) {
if (param.offset +
ldiskfs_itable_unused_count(param.sb, desc) >
- LDISKFS_INODES_PER_GROUP(param.sb))
+ LDISKFS_INODES_PER_GROUP(param.sb)) {
+ *pos = 1 + (param.bg + 1) *
+ LDISKFS_INODES_PER_GROUP(param.sb);
goto next_group;
+ }
rc = next(info, dev, ¶m, &oic, noslot);
switch (rc) {
RETURN(rc);
rc = osd_scrub_refresh_mapping(info, dev, &tfid, id,
- DTO_INDEX_INSERT, true, 0);
+ DTO_INDEX_INSERT, true, 0, NULL);
if (rc > 0)
rc = 0;
}
rc = osd_scrub_refresh_mapping(info, dev, &tfid, id,
- DTO_INDEX_UPDATE, true, 0);
+ DTO_INDEX_UPDATE, true, 0, NULL);
if (rc > 0)
rc = 0;
* or filter_fid_old), move them back to its proper /O/<seq>/d<x>.
*/
#ifdef HAVE_FILLDIR_USE_CTX
-static int osd_ios_lf_fill(struct dir_context *buf, const char *name,
- int namelen,
+static int osd_ios_lf_fill(struct dir_context *buf,
#else
-static int osd_ios_lf_fill(void *buf, const char *name, int namelen,
+static int osd_ios_lf_fill(void *buf,
#endif
+ const char *name, int namelen,
loff_t offset, __u64 ino, unsigned d_type)
{
struct osd_ios_filldir_buf *fill_buf =
}
#ifdef HAVE_FILLDIR_USE_CTX
-static int osd_ios_varfid_fill(struct dir_context *buf, const char *name,
- int namelen,
+static int osd_ios_varfid_fill(struct dir_context *buf,
#else
-static int osd_ios_varfid_fill(void *buf, const char *name, int namelen,
+static int osd_ios_varfid_fill(void *buf,
#endif
+ const char *name, int namelen,
loff_t offset, __u64 ino, unsigned d_type)
{
struct osd_ios_filldir_buf *fill_buf =
}
#ifdef HAVE_FILLDIR_USE_CTX
-static int osd_ios_dl_fill(struct dir_context *buf, const char *name,
- int namelen,
+static int osd_ios_dl_fill(struct dir_context *buf,
#else
-static int osd_ios_dl_fill(void *buf, const char *name, int namelen,
+static int osd_ios_dl_fill(void *buf,
#endif
+ const char *name, int namelen,
loff_t offset, __u64 ino, unsigned d_type)
{
struct osd_ios_filldir_buf *fill_buf =
}
#ifdef HAVE_FILLDIR_USE_CTX
-static int osd_ios_uld_fill(struct dir_context *buf, const char *name,
- int namelen,
+static int osd_ios_uld_fill(struct dir_context *buf,
#else
-static int osd_ios_uld_fill(void *buf, const char *name, int namelen,
+static int osd_ios_uld_fill(void *buf,
#endif
+ const char *name, int namelen,
loff_t offset, __u64 ino, unsigned d_type)
{
struct osd_ios_filldir_buf *fill_buf =
}
#ifdef HAVE_FILLDIR_USE_CTX
-static int osd_ios_root_fill(struct dir_context *buf, const char *name,
- int namelen,
+static int osd_ios_root_fill(struct dir_context *buf,
#else
-static int osd_ios_root_fill(void *buf, const char *name, int namelen,
+static int osd_ios_root_fill(void *buf,
#endif
+ const char *name, int namelen,
loff_t offset, __u64 ino, unsigned d_type)
{
struct osd_ios_filldir_buf *fill_buf =
else if (PTR_ERR(child) == -ENOENT)
osd_scrub_refresh_mapping(info, dev, &map->olm_fid,
NULL, DTO_INDEX_DELETE,
- true, 0);
+ true, 0, NULL);
map++;
}
again:
if (thread_is_running(thread)) {
spin_unlock(&scrub->os_lock);
- if (!(scrub->os_file.sf_flags & SF_AUTO) ||
- (flags & (SS_AUTO_FULL | SS_AUTO_PARTIAL)))
+ if (!(scrub->os_file.sf_flags & SF_AUTO ||
+ scrub->os_partial_scan) ||
+ (flags & SS_AUTO_PARTIAL))
RETURN(-EALREADY);
osd_scrub_join(dev, flags, false);
RETURN(PTR_ERR(filp));
}
- inode = filp->f_path.dentry->d_inode;
+ inode = file_inode(filp);
/* 'What the @fid is' is not imporatant, because the object
* has no OI mapping, and only is visible inside the OSD.*/
lu_igif_build(fid, inode->i_ino, inode->i_generation);
if (it->ooi_user_ready)
RETURN(-EPERM);
+ LASSERT(!scrub->os_partial_scan);
+
if (hash > OSD_OTABLE_MAX_HASH)
hash = OSD_OTABLE_MAX_HASH;