* Author: Di Wang <di.wang@intel.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_OSD
#include <lustre_ver.h>
if (rc)
return rc;
- strncpy(oi->oi_name, name, OSD_OI_NAME_SIZE - 1);
+ rc = strlcpy(oi->oi_name, name, sizeof(oi->oi_name));
+ if (rc >= sizeof(oi->oi_name))
+ return -E2BIG;
+
+ rc = 0;
oi->oi_zapid = zde->zde_dnode;
return rc;
* the object is located (tgt index) and it is MDT or OST object.
*/
int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd,
- const struct lu_fid *fid, struct lu_seq_range *range)
+ obd_seq seq, struct lu_seq_range *range)
{
struct seq_server_site *ss = osd_seq_site(osd);
- int rc;
- if (fid_is_idif(fid)) {
+ if (fid_seq_is_idif(seq)) {
fld_range_set_ost(range);
- range->lsr_index = fid_idif_ost_idx(fid);
+ range->lsr_index = idif_ost_idx(seq);
return 0;
}
- if (!fid_seq_in_fldb(fid_seq(fid))) {
+ if (!fid_seq_in_fldb(seq)) {
fld_range_set_mdt(range);
if (ss != NULL)
/* FIXME: If ss is NULL, it suppose not get lsr_index
LASSERT(ss != NULL);
fld_range_set_any(range);
- rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(fid), range);
- if (rc != 0)
- CERROR("%s: cannot find FLD range for "DFID": rc = %d\n",
- osd_name(osd), PFID(fid), rc);
- return rc;
+ /* OSD will only do local fld lookup */
+ return fld_local_lookup(env, ss->ss_server_fld, seq, range);
}
int fid_is_on_ost(const struct lu_env *env, struct osd_device *osd,
const struct lu_fid *fid)
{
- struct lu_seq_range *range = &osd_oti_get(env)->oti_seq_range;
- int rc;
+ struct lu_seq_range *range = &osd_oti_get(env)->oti_seq_range;
+ int rc;
ENTRY;
if (fid_is_idif(fid))
RETURN(1);
- rc = osd_fld_lookup(env, osd, fid, range);
+ if (unlikely(fid_is_local_file(fid) || fid_is_llog(fid)) ||
+ fid_is_name_llog(fid) || fid_is_quota(fid))
+ RETURN(0);
+
+ rc = osd_fld_lookup(env, osd, fid_seq(fid), range);
if (rc != 0) {
- CERROR("%s: Can not lookup fld for "DFID"\n",
- osd_name(osd), PFID(fid));
- RETURN(rc);
+ if (rc != -ENOENT)
+ CERROR("%s: "DFID" lookup failed: rc = %d\n",
+ osd_name(osd), PFID(fid), rc);
+ RETURN(0);
}
- CDEBUG(D_INFO, "fid "DFID" range "DRANGE"\n", PFID(fid),
- PRANGE(range));
-
if (fld_range_is_ost(range))
RETURN(1);
{
struct osd_seq *osd_seq;
- cfs_list_for_each_entry(osd_seq, &seq_list->osl_seq_list, os_seq_list) {
+ list_for_each_entry(osd_seq, &seq_list->osl_seq_list, os_seq_list) {
if (osd_seq->os_seq == seq)
return osd_seq;
}
if (osd_seq == NULL)
GOTO(out, rc = -ENOMEM);
- CFS_INIT_LIST_HEAD(&osd_seq->os_seq_list);
+ INIT_LIST_HEAD(&osd_seq->os_seq_list);
osd_seq->os_seq = seq;
/* Init subdir count to be 32, but each seq can have
if (osd_seq->os_compat_dirs == NULL)
GOTO(out, rc = -ENOMEM);
- rc = osd_oi_lookup(env, osd, osd->od_root, "O", &oi);
- if (rc != 0) {
- CERROR("%s: Can not find O: rc = %d\n", osd_name(osd), rc);
- GOTO(out, rc);
- }
-
+ oi.oi_zapid = osd->od_O_id;
sprintf(seq_name, (fid_seq_is_rsvd(seq) ||
fid_seq_is_mdt0(seq)) ? LPU64 : LPX64i,
fid_seq_is_idif(seq) ? 0 : seq);
sprintf(key, "d%d", i);
rc = osd_oi_find_or_create(env, osd, odb, key, &sdb);
if (rc)
- GOTO(out, osd_seq = ERR_PTR(rc));
+ GOTO(out, rc);
osd_seq->os_compat_dirs[i] = sdb;
}
write_lock(&seq_list->osl_seq_list_lock);
- cfs_list_add(&osd_seq->os_seq_list, &seq_list->osl_seq_list);
+ list_add(&osd_seq->os_seq_list, &seq_list->osl_seq_list);
write_unlock(&seq_list->osl_seq_list_lock);
out:
up(&seq_list->osl_seq_init_sem);
{
struct osd_seq *osd_seq;
unsigned long b;
+ obd_id id;
int rc;
osd_seq = osd_find_or_add_seq(env, osd, fid_seq(fid));
return PTR_ERR(osd_seq);
}
- rc = fid_to_ostid(fid, &osd_oti_get(env)->oti_ostid);
- LASSERT(rc == 0); /* we should not get here with IGIF */
- b = ostid_id(&osd_oti_get(env)->oti_ostid) % OSD_OST_MAP_SIZE;
+ if (fid_is_last_id(fid)) {
+ id = 0;
+ } else {
+ rc = fid_to_ostid(fid, &osd_oti_get(env)->oti_ostid);
+ LASSERT(rc == 0); /* we should not get here with IGIF */
+ id = ostid_id(&osd_oti_get(env)->oti_ostid);
+ }
+
+ b = id % OSD_OST_MAP_SIZE;
LASSERT(osd_seq->os_compat_dirs[b]);
- sprintf(buf, LPU64, ostid_id(&osd_oti_get(env)->oti_ostid));
+ sprintf(buf, LPU64, id);
return osd_seq->os_compat_dirs[b];
}
*oid = info->oti_zde.lzd_reg.zde_dnode;
}
+ if (rc == 0)
+ dmu_prefetch(dev->od_objset.os, *oid, 0, 0);
+
RETURN(rc);
}
{
struct osd_seq_list *osl = &osd->od_seq_list;
- CFS_INIT_LIST_HEAD(&osl->osl_seq_list);
+ INIT_LIST_HEAD(&osl->osl_seq_list);
rwlock_init(&osl->osl_seq_list_lock);
sema_init(&osl->osl_seq_init_sem, 1);
}
struct osd_seq *osd_seq, *tmp;
write_lock(&osl->osl_seq_list_lock);
- cfs_list_for_each_entry_safe(osd_seq, tmp, &osl->osl_seq_list,
- os_seq_list) {
- cfs_list_del(&osd_seq->os_seq_list);
+ list_for_each_entry_safe(osd_seq, tmp, &osl->osl_seq_list,
+ os_seq_list) {
+ list_del(&osd_seq->os_seq_list);
OBD_FREE(osd_seq->os_compat_dirs,
sizeof(uint64_t) * osd_seq->os_subdir_count);
OBD_FREE(osd_seq, sizeof(*osd_seq));
if (rc)
RETURN(rc);
+ o->od_O_id = sdb;
+
osd_ost_seq_init(env, o);
/* Create on-disk indexes to maintain per-UID/GID inode usage.
* Those new indexes are created in the top-level ZAP outside the