Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
LU-7898 osd: remove unnecessary declarations
[fs/lustre-release.git]
/
lustre
/
osd-zfs
/
osd_oi.c
diff --git
a/lustre/osd-zfs/osd_oi.c
b/lustre/osd-zfs/osd_oi.c
index
560c90f
..
6d3df99
100644
(file)
--- a/
lustre/osd-zfs/osd_oi.c
+++ b/
lustre/osd-zfs/osd_oi.c
@@
-142,8
+142,9
@@
osd_oi_create(const struct lu_env *env, struct osd_device *o,
{
struct zpl_direntry *zde = &osd_oti_get(env)->oti_zde.lzd_reg;
struct lu_attr *la = &osd_oti_get(env)->oti_la;
-
dmu_buf_t *db
;
+
sa_handle_t *sa_hdl = NULL
;
dmu_tx_t *tx;
+ uint64_t oid;
int rc;
/* verify it doesn't already exist */
@@
-168,21
+169,36
@@
osd_oi_create(const struct lu_env *env, struct osd_device *o,
return rc;
}
+ oid = zap_create_flags(o->od_os, 0, ZAP_FLAG_HASH64,
+ DMU_OT_DIRECTORY_CONTENTS,
+ 14, /* == ZFS fzap_default_block_shift */
+ DN_MAX_INDBLKSHIFT, /* indirect block shift */
+ DMU_OT_SA, DN_MAX_BONUSLEN, tx);
+
+ rc = -sa_handle_get(o->od_os, oid, NULL, SA_HDL_PRIVATE, &sa_hdl);
+ if (rc)
+ goto commit;
la->la_valid = LA_MODE | LA_UID | LA_GID;
la->la_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
la->la_uid = la->la_gid = 0;
- __osd_zap_create(env, o, &db, tx, la, parent, 0);
+ rc = __osd_attr_init(env, o, sa_hdl, tx, la, parent);
+ sa_handle_destroy(sa_hdl);
+ if (rc)
+ goto commit;
- zde->zde_dnode =
db->db_object
;
+ zde->zde_dnode =
oid
;
zde->zde_pad = 0;
zde->zde_type = IFTODT(S_IFDIR);
rc = -zap_add(o->od_os, parent, name, 8, 1, (void *)zde, tx);
+commit:
+ if (rc)
+ dmu_object_free(o->od_os, oid, tx);
dmu_tx_commit(tx);
- *child = db->db_object;
-
sa_buf_rele(db, osd_obj_tag)
;
+ if (rc == 0)
+
*child = oid
;
return rc;
}
@@
-366,7
+382,7
@@
out:
*/
static uint64_t
osd_get_idx_for_ost_obj(const struct lu_env *env, struct osd_device *osd,
- const struct lu_fid *fid, char *buf)
+ const struct lu_fid *fid, char *buf
, int bufsize
)
{
struct osd_seq *osd_seq;
unsigned long b;
@@
-391,7
+407,8
@@
osd_get_idx_for_ost_obj(const struct lu_env *env, struct osd_device *osd,
b = id % OSD_OST_MAP_SIZE;
LASSERT(osd_seq->os_compat_dirs[b]);
- sprintf(buf, LPU64, id);
+ if (buf)
+ snprintf(buf, bufsize, LPU64, id);
return osd_seq->os_compat_dirs[b];
}
@@
-416,28
+433,29
@@
osd_get_idx_for_fid(struct osd_device *osd, const struct lu_fid *fid,
LASSERT(osd->od_oi_table != NULL);
oi = osd->od_oi_table[fid_seq(fid) & (osd->od_oi_count - 1)];
- osd_fid2str(buf, fid);
+ if (buf)
+ osd_fid2str(buf, fid);
return oi->oi_zapid;
}
uint64_t osd_get_name_n_idx(const struct lu_env *env, struct osd_device *osd,
- const struct lu_fid *fid, char *buf)
+ const struct lu_fid *fid, char *buf
, int bufsize
)
{
uint64_t zapid;
LASSERT(fid);
- LASSERT(buf);
if (fid_is_on_ost(env, osd, fid) == 1 || fid_seq(fid) == FID_SEQ_ECHO) {
- zapid = osd_get_idx_for_ost_obj(env, osd, fid, buf);
+ zapid = osd_get_idx_for_ost_obj(env, osd, fid, buf
, bufsize
);
} else if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) {
/* special objects with fixed known fids get their name */
char *name = oid2name(fid_oid(fid));
if (name) {
zapid = osd->od_root;
- strcpy(buf, name);
+ if (buf)
+ strncpy(buf, name, bufsize);
if (fid_is_acct(fid))
zapid = MASTER_NODE_OBJ;
} else {
@@
-477,8
+495,8
@@
int osd_fid_lookup(const struct lu_env *env, struct osd_device *dev,
} else if (unlikely(fid_is_fs_root(fid))) {
*oid = dev->od_root;
} else {
- zapid = osd_get_name_n_idx(env, dev, fid, buf
);
-
+ zapid = osd_get_name_n_idx(env, dev, fid, buf
,
+ sizeof(info->oti_buf));
rc = -zap_lookup(dev->od_os, zapid, buf,
8, 1, &info->oti_zde);
if (rc)