#include <lustre_net.h>
#include <lustre_fid.h>
/* process_config */
-#include <lustre_param.h>
+#include <uapi/linux/lustre_param.h>
#include "osd_internal.h"
#include "osd_dynlocks.h"
lustre_loa_swab(loa, true);
/* Check LMA compatibility */
if (lma->lma_incompat & ~LMA_INCOMPAT_SUPP) {
- CWARN("%.16s: unsupported incompat LMA feature(s) %#x "
+ CWARN("%s: unsupported incompat LMA feature(s) %#x "
"for fid = "DFID", ino = %lu\n",
- LDISKFS_SB(inode->i_sb)->s_es->s_volume_name,
+ osd_ino2name(inode),
lma->lma_incompat & ~LMA_INCOMPAT_SUPP,
PFID(&lma->lma_self_fid), inode->i_ino);
rc = -EOPNOTSUPP;
iput(inode);
inode = ERR_PTR(-ESTALE);
} else if (is_bad_inode(inode)) {
- CWARN("%.16s: bad inode: ino = %u\n",
- LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name, id->oii_ino);
+ CWARN("%s: bad inode: ino = %u\n",
+ osd_dev2name(dev), id->oii_ino);
iput(inode);
inode = ERR_PTR(-ENOENT);
} else if ((rc = osd_attach_jinode(inode))) {
/* It is the OI scrub updated the OI mapping by race.
* The new OI mapping must be valid. */
- if (saved_ino != id->oii_ino || saved_gen != id->oii_gen) {
+ if (saved_ino != id->oii_ino ||
+ (saved_gen != id->oii_gen && saved_gen != OSD_OII_NOGEN)) {
+ if (!IS_ERR(inode))
+ iput(inode);
+
trusted = true;
goto again;
}
out:
if (rc < 0)
- CDEBUG(D_LFSCK, "%.16s: fail to check LMV EA, inode = %lu/%u,"
- DFID": rc = %d\n",
- LDISKFS_SB(inode->i_sb)->s_es->s_volume_name,
+ CDEBUG(D_LFSCK, "%s: fail to check LMV EA, inode = %lu/%u,"
+ DFID": rc = %d\n", osd_ino2name(inode),
inode->i_ino, inode->i_generation,
PFID(&oic->oic_fid), rc);
else
* shouldn't never be re-used, if it's really a duplicate FID from
* unexpected reason, we should be able to detect it later by calling
* do_create->osd_oi_insert(). */
- if (conf != NULL && conf->loc_flags & LOC_F_NEW)
+ if (conf && conf->loc_flags & LOC_F_NEW)
GOTO(out, result = 0);
/* Search order: 1. per-thread cache. */
- if (lu_fid_eq(fid, &oic->oic_fid) &&
- likely(oic->oic_dev == dev)) {
+ if (lu_fid_eq(fid, &oic->oic_fid) && likely(oic->oic_dev == dev)) {
id = &oic->oic_lid;
goto iget;
}
if (!list_empty(&scrub->os_inconsistent_items)) {
/* Search order: 2. OI scrub pending list. */
result = osd_oii_lookup(dev, fid, id);
- if (result == 0)
+ if (!result)
goto iget;
}
goto trigger;
}
- if (result != 0)
+ if (result)
GOTO(out, result);
iget:
+ obj->oo_inode = NULL;
+ /* for later passes through checks, not true on first pass */
+ if (!IS_ERR_OR_NULL(inode))
+ iput(inode);
+
inode = osd_iget_check(info, dev, fid, id, trusted);
- if (IS_ERR(inode)) {
- result = PTR_ERR(inode);
- if (result == -ENOENT || result == -ESTALE)
- GOTO(out, result = 0);
+ if (!IS_ERR(inode)) {
+ obj->oo_inode = inode;
+ result = 0;
+ if (remote)
+ goto trigger;
- if (result == -EREMCHG) {
+ goto check_lma;
+ }
-trigger:
- /* We still have chance to get the valid inode: for the
- * object which is referenced by remote name entry, the
- * object on the local MDT will be linked under the dir
- * of "/REMOTE_PARENT_DIR" with its FID string as name.
- *
- * We do not know whether the object for the given FID
- * is referenced by some remote name entry or not, and
- * especially for DNE II, a multiple-linked object may
- * have many name entries reside on many MDTs.
- *
- * To simplify the operation, OSD will not distinguish
- * more, just lookup "/REMOTE_PARENT_DIR". Usually, it
- * only happened for the RPC from other MDT during the
- * OI scrub, or for the client side RPC with FID only,
- * such as FID to path, or from old connected client. */
- if (!remote &&
- !fid_is_on_ost(info, dev, fid, OI_CHECK_FLD)) {
- rc1 = osd_lookup_in_remote_parent(info, dev,
- fid, id);
- if (rc1 == 0) {
- remote = true;
- trusted = true;
- flags |= SS_AUTO_PARTIAL;
- flags &= ~SS_AUTO_FULL;
- goto iget;
- }
- }
+ result = PTR_ERR(inode);
+ if (result == -ENOENT || result == -ESTALE)
+ GOTO(out, result = 0);
- if (thread_is_running(&scrub->os_thread)) {
- if (scrub->os_partial_scan &&
- !scrub->os_in_join) {
- goto join;
- } else {
- if (inode != NULL && !IS_ERR(inode)) {
- LASSERT(remote);
-
- osd_add_oi_cache(info, dev, id,
- fid);
- osd_oii_insert(dev, oic, true);
- } else {
- result = -EINPROGRESS;
- }
- }
- } else if (!dev->od_noscrub) {
+ if (result != -EREMCHG)
+ GOTO(out, result);
-join:
- rc1 = osd_scrub_start(dev, flags);
- LCONSOLE_WARN("%.16s: trigger OI scrub by RPC "
- "for the "DFID" with flags 0x%x,"
- " rc = %d\n", osd_name(dev),
- PFID(fid), flags, rc1);
- if (rc1 == 0 || rc1 == -EALREADY) {
- if (inode != NULL && !IS_ERR(inode)) {
- LASSERT(remote);
-
- osd_add_oi_cache(info, dev, id,
- fid);
- osd_oii_insert(dev, oic, true);
- } else {
- result = -EINPROGRESS;
- }
- } else {
- result = -EREMCHG;
- }
- } else {
- result = -EREMCHG;
- }
+trigger:
+ /* We still have chance to get the valid inode: for the
+ * object which is referenced by remote name entry, the
+ * object on the local MDT will be linked under the dir
+ * of "/REMOTE_PARENT_DIR" with its FID string as name.
+ *
+ * We do not know whether the object for the given FID
+ * is referenced by some remote name entry or not, and
+ * especially for DNE II, a multiple-linked object may
+ * have many name entries reside on many MDTs.
+ *
+ * To simplify the operation, OSD will not distinguish
+ * more, just lookup "/REMOTE_PARENT_DIR". Usually, it
+ * only happened for the RPC from other MDT during the
+ * OI scrub, or for the client side RPC with FID only,
+ * such as FID to path, or from old connected client. */
+ if (!remote && !fid_is_on_ost(info, dev, fid, OI_CHECK_FLD)) {
+ rc1 = osd_lookup_in_remote_parent(info, dev, fid, id);
+ if (!rc1) {
+ remote = true;
+ trusted = true;
+ flags |= SS_AUTO_PARTIAL;
+ flags &= ~SS_AUTO_FULL;
+ goto iget;
}
+ }
- if (inode == NULL || IS_ERR(inode))
- GOTO(out, result);
- } else if (remote) {
- goto trigger;
+ if (thread_is_running(&scrub->os_thread)) {
+ if (scrub->os_partial_scan && !scrub->os_in_join)
+ goto join;
+
+ if (IS_ERR_OR_NULL(inode) || result)
+ GOTO(out, result = -EINPROGRESS);
+
+ LASSERT(remote);
+ LASSERT(obj->oo_inode == inode);
+
+ osd_add_oi_cache(info, dev, id, fid);
+ osd_oii_insert(dev, oic, true);
+ goto found;
}
- obj->oo_inode = inode;
- LASSERT(obj->oo_inode->i_sb == osd_sb(dev));
+ if (dev->od_noscrub) {
+ if (!remote)
+ GOTO(out, result = -EREMCHG);
+
+ LASSERT(!result);
+ LASSERT(obj->oo_inode == inode);
+
+ osd_add_oi_cache(info, dev, id, fid);
+ goto found;
+ }
+
+join:
+ rc1 = osd_scrub_start(dev, flags);
+ LCONSOLE_WARN("%s: trigger OI scrub by RPC for the " DFID" with flags "
+ "0x%x, rc = %d\n", osd_name(dev), PFID(fid), flags, rc1);
+ if (rc1 && rc1 != -EALREADY)
+ GOTO(out, result = -EREMCHG);
+
+ if (IS_ERR_OR_NULL(inode) || result)
+ GOTO(out, result = -EINPROGRESS);
+
+ LASSERT(remote);
+ LASSERT(obj->oo_inode == inode);
+ osd_add_oi_cache(info, dev, id, fid);
+ osd_oii_insert(dev, oic, true);
+ goto found;
+
+check_lma:
result = osd_check_lma(env, obj);
- if (result == 0)
+ if (!result)
goto found;
LASSERTF(id->oii_ino == inode->i_ino &&
goto found;
result = osd_oi_lookup(info, dev, fid, id, OI_CHECK_FLD);
- if (result == 0) {
+ if (!result) {
/* The OI mapping is still there, the inode is still
* valid. It is just becaues the inode has no LMA EA. */
if (saved_ino == id->oii_ino &&
/* It is the OI scrub updated the OI mapping by race.
* The new OI mapping must be valid. */
- iput(inode);
- inode = NULL;
- obj->oo_inode = NULL;
trusted = true;
updated = true;
goto iget;
if (result == -ENOENT) {
LASSERT(trusted);
+ obj->oo_inode = NULL;
result = 0;
}
}
- iput(inode);
- inode = NULL;
- obj->oo_inode = NULL;
-
if (result != -EREMCHG)
GOTO(out, result);
if (result == -ENOENT) {
LASSERT(trusted);
+ obj->oo_inode = NULL;
GOTO(out, result = 0);
}
- if (result != 0)
+ if (result)
GOTO(out, result);
- if (saved_ino == id->oii_ino && saved_gen == id->oii_gen)
+ if (saved_ino == id->oii_ino && saved_gen == id->oii_gen) {
+ result = -EREMCHG;
goto trigger;
+ }
/* It is the OI scrub updated the OI mapping by race.
* The new OI mapping must be valid. */
osd_check_lmv(info, dev, inode, oic);
result = osd_attach_jinode(inode);
- if (result) {
- obj->oo_inode = NULL;
- iput(inode);
+ if (result)
GOTO(out, result);
- }
if (!ldiskfs_pdo)
GOTO(out, result = 0);
- LASSERT(obj->oo_hl_head == NULL);
+ LASSERT(!obj->oo_hl_head);
obj->oo_hl_head = ldiskfs_htree_lock_head_alloc(HTREE_HBITS_DEF);
- if (obj->oo_hl_head == NULL) {
- obj->oo_inode = NULL;
- iput(inode);
- GOTO(out, result = -ENOMEM);
- }
- GOTO(out, result = 0);
+
+ GOTO(out, result = (!obj->oo_hl_head ? -ENOMEM : 0));
out:
- if (result != 0 && trusted)
- fid_zero(&oic->oic_fid);
+ if (result || !obj->oo_inode) {
+ if (!IS_ERR_OR_NULL(inode))
+ iput(inode);
+
+ obj->oo_inode = NULL;
+ if (trusted)
+ fid_zero(&oic->oic_fid);
+ }
LINVRNT(osd_invariant(obj));
return result;
RETURN(s->s_op->sync_fs(s, 0));
}
+/* Our own copy of the set readonly functions if present, or NU if not. */
+static int (*priv_dev_set_rdonly)(struct block_device *bdev);
+static int (*priv_dev_check_rdonly)(struct block_device *bdev);
+/* static int (*priv_dev_clear_rdonly)(struct block_device *bdev); */
+
/*
* Concurrency: shouldn't matter.
*/
-
static int osd_ro(const struct lu_env *env, struct dt_device *d)
{
struct super_block *sb = osd_sb(osd_dt_dev(d));
struct block_device *dev = sb->s_bdev;
-#ifdef HAVE_DEV_SET_RDONLY
- struct block_device *jdev = LDISKFS_SB(sb)->journal_bdev;
- int rc = 0;
-#else
int rc = -EOPNOTSUPP;
-#endif
ENTRY;
-#ifdef HAVE_DEV_SET_RDONLY
- CERROR("*** setting %s read-only ***\n", osd_dt_dev(d)->od_svname);
+ if (priv_dev_set_rdonly) {
+ struct block_device *jdev = LDISKFS_SB(sb)->journal_bdev;
- if (sb->s_op->freeze_fs) {
- rc = sb->s_op->freeze_fs(sb);
- if (rc)
- goto out;
- }
+ rc = 0;
+ CERROR("*** setting %s read-only ***\n",
+ osd_dt_dev(d)->od_svname);
- if (jdev && (jdev != dev)) {
- CDEBUG(D_IOCTL | D_HA, "set journal dev %lx rdonly\n",
- (long)jdev);
- dev_set_rdonly(jdev);
- }
- CDEBUG(D_IOCTL | D_HA, "set dev %lx rdonly\n", (long)dev);
- dev_set_rdonly(dev);
+ if (sb->s_op->freeze_fs) {
+ rc = sb->s_op->freeze_fs(sb);
+ if (rc)
+ goto out;
+ }
- if (sb->s_op->unfreeze_fs)
- sb->s_op->unfreeze_fs(sb);
+ if (jdev && (jdev != dev)) {
+ CDEBUG(D_IOCTL | D_HA, "set journal dev %lx rdonly\n",
+ (long)jdev);
+ priv_dev_set_rdonly(jdev);
+ }
+ CDEBUG(D_IOCTL | D_HA, "set dev %lx rdonly\n", (long)dev);
+ priv_dev_set_rdonly(dev);
+
+ if (sb->s_op->unfreeze_fs)
+ sb->s_op->unfreeze_fs(sb);
+ }
out:
-#endif
if (rc)
CERROR("%s: %lx CANNOT BE SET READONLY: rc = %d\n",
osd_dt_dev(d)->od_svname, (long)dev, rc);
if (gen != OSD_OII_NOGEN)
goto trigger;
- iput(inode);
/* The inode may has been reused by others, we do not know,
* leave it to be handled by subsequent osd_fid_lookup(). */
- RETURN(0);
- } else if (rc != 0 || osd_id_eq(id, &oti->oti_id)) {
- RETURN(rc);
- } else {
- insert = false;
+ GOTO(out, rc = 0);
+ } else if (rc || osd_id_eq(id, &oti->oti_id)) {
+ GOTO(out, rc);
}
+ insert = false;
+
trigger:
if (thread_is_running(&scrub->os_thread)) {
if (inode == NULL) {
else
rc = osd_check_lmv(oti, dev, inode, oic);
- iput(inode);
- RETURN(rc);
+ GOTO(out, rc);
}
if (!dev->od_noscrub && ++once == 1) {
rc = osd_scrub_start(dev, SS_AUTO_PARTIAL | SS_CLEAR_DRYRUN |
SS_CLEAR_FAILOUT);
CDEBUG(D_LFSCK | D_CONSOLE | D_WARNING,
- "%.16s: trigger partial OI scrub for RPC inconsistency "
+ "%s: trigger partial OI scrub for RPC inconsistency "
"checking FID "DFID": rc = %d\n",
- LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name,
- PFID(fid), rc);
+ osd_dev2name(dev), PFID(fid), rc);
if (rc == 0 || rc == -EALREADY)
goto again;
}
- if (inode != NULL)
+ GOTO(out, rc);
+
+out:
+ if (inode)
iput(inode);
RETURN(rc);
/* It is too bad, we cannot reinsert the name entry back.
* That means we lose it! */
if (rc != 0)
- CDEBUG(D_LFSCK, "%.16s: fail to reinsert the dirent, "
+ CDEBUG(D_LFSCK, "%s: fail to reinsert the dirent, "
"dir = %lu/%u, name = %.*s, "DFID": rc = %d\n",
- LDISKFS_SB(inode->i_sb)->s_es->s_volume_name,
+ osd_ino2name(inode),
dir->i_ino, dir->i_generation, namelen,
dentry->d_name.name, PFID(fid), rc);
}
if (lmd_flags & LMD_FLG_DEV_RDONLY) {
-#ifdef HAVE_DEV_SET_RDONLY
- dev_set_rdonly(osd_sb(o)->s_bdev);
- o->od_dt_dev.dd_rdonly = 1;
- LCONSOLE_WARN("%s: set dev_rdonly on this device\n", name);
-#else
- LCONSOLE_WARN("%s: not support dev_rdonly on this device",
- name);
-
- GOTO(out_mnt, rc = -EOPNOTSUPP);
-#endif
- } else {
-#ifdef HAVE_DEV_SET_RDONLY
- if (dev_check_rdonly(osd_sb(o)->s_bdev)) {
- CERROR("%s: underlying device %s is marked as "
- "read-only. Setup failed\n", name, dev);
+ if (priv_dev_set_rdonly) {
+ priv_dev_set_rdonly(osd_sb(o)->s_bdev);
+ o->od_dt_dev.dd_rdonly = 1;
+ LCONSOLE_WARN("%s: set dev_rdonly on this device\n",
+ name);
+ } else {
+ LCONSOLE_WARN("%s: not support dev_rdonly on this device",
+ name);
- GOTO(out_mnt, rc = -EROFS);
+ GOTO(out_mnt, rc = -EOPNOTSUPP);
}
-#endif
+ } else if (priv_dev_check_rdonly &&
+ priv_dev_check_rdonly(osd_sb(o)->s_bdev)) {
+ CERROR("%s: underlying device %s is marked as "
+ "read-only. Setup failed\n", name, dev);
+
+ GOTO(out_mnt, rc = -EROFS);
}
if (!LDISKFS_HAS_COMPAT_FEATURE(o->od_mnt->mnt_sb,
LASSERT(&o->od_dt_dev);
rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars,
cfg, &o->od_dt_dev);
- if (rc > 0 || rc == -ENOSYS)
+ if (rc > 0 || rc == -ENOSYS) {
rc = class_process_proc_param(PARAM_OST,
lprocfs_osd_obd_vars,
cfg, &o->od_dt_dev);
+ if (rc > 0)
+ rc = 0;
+ }
break;
default:
rc = -ENOSYS;
if (rc)
return rc;
+#ifdef CONFIG_KALLSYMS
+ priv_dev_set_rdonly = (void *)kallsyms_lookup_name("dev_set_rdonly");
+ priv_dev_check_rdonly = (void *)kallsyms_lookup_name("dev_check_rdonly");
+ /* Clear readonly is unused at this time */
+ /*priv_dev_clear_rdonly = (void *)kallsyms_lookup_name("dev_clear_rdonly");*/
+#endif
+
rc = class_register_type(&osd_obd_device_ops, NULL, true,
lprocfs_osd_module_vars,
LUSTRE_OSD_LDISKFS_NAME, &osd_device_type);