*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#define DEBUG_SUBSYSTEM S_CLASS
+#include <linux/list.h>
#include <obd.h>
#include <dt_object.h>
-#include <libcfs/list.h>
/* fid_be_to_cpu() */
#include <lustre_fid.h>
-
+#include <lustre_nodemap.h>
#include <lustre_quota.h>
/* context key constructor/destructor: dt_global_key_init, dt_global_key_fini */
.lct_init = dt_global_key_init,
.lct_fini = dt_global_key_fini
};
-EXPORT_SYMBOL(dt_key);
/* no lock is necessary to protect the list, because call-backs
* are added during system startup. Please refer to "struct dt_device".
int dt_txn_hook_start(const struct lu_env *env,
struct dt_device *dev, struct thandle *th)
{
- int rc = 0;
- struct dt_txn_callback *cb;
+ int rc = 0;
+ struct dt_txn_callback *cb;
- if (th->th_local)
- return 0;
+ if (th->th_local)
+ return 0;
list_for_each_entry(cb, &dev->dd_txn_callbacks, dtc_linkage) {
- if (cb->dtc_txn_start == NULL ||
- !(cb->dtc_tag & env->le_ctx.lc_tags))
- continue;
- rc = cb->dtc_txn_start(env, th, cb->dtc_cookie);
- if (rc < 0)
- break;
- }
- return rc;
+ struct thandle *dtc_th = th;
+
+ if (cb->dtc_txn_start == NULL ||
+ !(cb->dtc_tag & env->le_ctx.lc_tags))
+ continue;
+
+ /* Usually dt_txn_hook_start is called from bottom device,
+ * and if the thandle has th_top, then we need use top
+ * thandle for the callback in the top thandle layer */
+ if (th->th_top != NULL)
+ dtc_th = th->th_top;
+
+ rc = cb->dtc_txn_start(env, dtc_th, cb->dtc_cookie);
+ if (rc < 0)
+ break;
+ }
+ return rc;
}
EXPORT_SYMBOL(dt_txn_hook_start);
-int dt_txn_hook_stop(const struct lu_env *env, struct thandle *txn)
+int dt_txn_hook_stop(const struct lu_env *env, struct thandle *th)
{
- struct dt_device *dev = txn->th_dev;
- struct dt_txn_callback *cb;
- int rc = 0;
+ struct dt_device *dev = th->th_dev;
+ struct dt_txn_callback *cb;
+ int rc = 0;
+
+ if (th->th_local)
+ return 0;
- if (txn->th_local)
- return 0;
+ if (OBD_FAIL_CHECK(OBD_FAIL_DT_TXN_STOP))
+ return -EIO;
list_for_each_entry(cb, &dev->dd_txn_callbacks, dtc_linkage) {
- if (cb->dtc_txn_stop == NULL ||
- !(cb->dtc_tag & env->le_ctx.lc_tags))
- continue;
- rc = cb->dtc_txn_stop(env, txn, cb->dtc_cookie);
- if (rc < 0)
- break;
- }
- return rc;
+ struct thandle *dtc_th = th;
+
+ if (cb->dtc_txn_stop == NULL ||
+ !(cb->dtc_tag & env->le_ctx.lc_tags))
+ continue;
+
+ /* Usually dt_txn_hook_stop is called from bottom device,
+ * and if the thandle has th_top, then we need use top
+ * thandle for the callback in the top thandle layer */
+ if (th->th_top != NULL)
+ dtc_th = th->th_top;
+
+ rc = cb->dtc_txn_stop(env, dtc_th, cb->dtc_cookie);
+ if (rc < 0)
+ break;
+ }
+ return rc;
}
EXPORT_SYMBOL(dt_txn_hook_stop);
-void dt_txn_hook_commit(struct thandle *txn)
+void dt_txn_hook_commit(struct thandle *th)
{
struct dt_txn_callback *cb;
- if (txn->th_local)
+ if (th->th_local)
return;
- list_for_each_entry(cb, &txn->th_dev->dd_txn_callbacks,
+ list_for_each_entry(cb, &th->th_dev->dd_txn_callbacks,
dtc_linkage) {
+ /* Right now, the bottom device (OSD) will use this hook
+ * commit to notify OSP, so we do not check and replace
+ * the thandle to top thandle now */
if (cb->dtc_txn_commit)
- cb->dtc_txn_commit(txn, cb->dtc_cookie);
+ cb->dtc_txn_commit(th, cb->dtc_cookie);
}
}
EXPORT_SYMBOL(dt_txn_hook_commit);
int dt_lookup_dir(const struct lu_env *env, struct dt_object *dir,
const char *name, struct lu_fid *fid)
{
- if (dt_try_as_dir(env, dir))
- return dt_lookup(env, dir, (struct dt_rec *)fid,
- (const struct dt_key *)name, BYPASS_CAPA);
- return -ENOTDIR;
+ if (dt_try_as_dir(env, dir))
+ return dt_lookup(env, dir, (struct dt_rec *)fid,
+ (const struct dt_key *)name);
+ return -ENOTDIR;
}
EXPORT_SYMBOL(dt_lookup_dir);
EXPORT_SYMBOL(dt_locate_at);
/**
- * find a object named \a entry in given \a dfh->dfh_o directory.
+ * find an object named \a entry in given \a dfh->dfh_o directory.
*/
static int dt_find_entry(const struct lu_env *env, const char *entry, void *data)
{
}
return obj;
}
-EXPORT_SYMBOL(dt_store_resolve);
static struct dt_object *dt_reg_open(const struct lu_env *env,
struct dt_device *dt,
}
return file;
}
-EXPORT_SYMBOL(dt_store_open);
struct dt_object *dt_find_or_create(const struct lu_env *env,
struct dt_device *dt,
int dt_read(const struct lu_env *env, struct dt_object *dt,
struct lu_buf *buf, loff_t *pos)
{
- LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
- return dt->do_body_ops->dbo_read(env, dt, buf, pos, BYPASS_CAPA);
+ LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
+ return dt->do_body_ops->dbo_read(env, dt, buf, pos);
}
EXPORT_SYMBOL(dt_read);
LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
- size = dt->do_body_ops->dbo_read(env, dt, buf, pos, BYPASS_CAPA);
-
+ size = dt->do_body_ops->dbo_read(env, dt, buf, pos);
if (size < 0)
return size;
return (size == (ssize_t)buf->lb_len) ? 0 : -EFAULT;
LASSERT(dt->do_body_ops);
LASSERT(dt->do_body_ops->dbo_write);
- size = dt->do_body_ops->dbo_write(env, dt, buf, pos, th, BYPASS_CAPA, 1);
-
+ size = dt->do_body_ops->dbo_write(env, dt, buf, pos, th, 1);
if (size < 0)
return size;
return (size == (ssize_t)buf->lb_len) ? 0 : -EFAULT;
vbuf.lb_buf = &version;
vbuf.lb_len = sizeof(version);
- rc = dt_xattr_set(env, o, &vbuf, xname, 0, th, BYPASS_CAPA);
+ rc = dt_xattr_set(env, o, &vbuf, xname, 0, th);
if (rc < 0)
CDEBUG(D_INODE, "Can't set version, rc %d\n", rc);
return;
LASSERT(o);
vbuf.lb_buf = &version;
vbuf.lb_len = sizeof(version);
- rc = dt_xattr_get(env, o, &vbuf, xname, BYPASS_CAPA);
+ rc = dt_xattr_get(env, o, &vbuf, xname);
if (rc != sizeof(version)) {
CDEBUG(D_INODE, "Can't get version, rc %d\n", rc);
version = 0;
const struct dt_index_features dt_otable_features;
EXPORT_SYMBOL(dt_otable_features);
-/* lfsck orphan */
-const struct dt_index_features dt_lfsck_orphan_features = {
+/* lfsck layout orphan */
+const struct dt_index_features dt_lfsck_layout_orphan_features = {
.dif_flags = 0,
.dif_keysize_min = sizeof(struct lu_fid),
.dif_keysize_max = sizeof(struct lu_fid),
.dif_recsize_max = sizeof(struct lu_orphan_rec),
.dif_ptrsize = 4
};
-EXPORT_SYMBOL(dt_lfsck_orphan_features);
+EXPORT_SYMBOL(dt_lfsck_layout_orphan_features);
-/* lfsck */
-const struct dt_index_features dt_lfsck_features = {
+/* lfsck layout dangling */
+const struct dt_index_features dt_lfsck_layout_dangling_features = {
+ .dif_flags = DT_IND_UPDATE,
+ .dif_keysize_min = sizeof(struct lu_fid),
+ .dif_keysize_max = sizeof(struct lu_fid),
+ .dif_recsize_min = sizeof(struct lu_fid),
+ .dif_recsize_max = sizeof(struct lu_fid),
+ .dif_ptrsize = 4
+};
+EXPORT_SYMBOL(dt_lfsck_layout_dangling_features);
+
+/* lfsck namespace */
+const struct dt_index_features dt_lfsck_namespace_features = {
.dif_flags = DT_IND_UPDATE,
.dif_keysize_min = sizeof(struct lu_fid),
.dif_keysize_max = sizeof(struct lu_fid),
.dif_recsize_max = sizeof(__u8),
.dif_ptrsize = 4
};
-EXPORT_SYMBOL(dt_lfsck_features);
+EXPORT_SYMBOL(dt_lfsck_namespace_features);
/* accounting indexes */
const struct dt_index_features dt_acct_features = {
};
EXPORT_SYMBOL(dt_quota_slv_features);
+/* nodemap files, nodemap_rec size asserted in nodemap_storage.c */
+const struct dt_index_features dt_nodemap_features = {
+ .dif_flags = DT_IND_UPDATE,
+ .dif_keysize_min = sizeof(__u64), /* 64-bit nodemap/record id */
+ .dif_keysize_max = sizeof(__u64), /* 64-bit nodemap/record id */
+ .dif_recsize_min = sizeof(union nodemap_rec), /* 32 bytes */
+ .dif_recsize_max = sizeof(union nodemap_rec), /* 32 bytes */
+ .dif_ptrsize = 4
+};
+EXPORT_SYMBOL(dt_nodemap_features);
+
/* helper function returning what dt_index_features structure should be used
* based on the FID sequence. This is used by OBD_IDX_READ RPC */
static inline const struct dt_index_features *dt_index_feat_select(__u64 seq,
return ERR_PTR(-ENOENT);
return &dt_quota_slv_features;
} else if (seq == FID_SEQ_LAYOUT_RBTREE){
- return &dt_lfsck_orphan_features;
+ return &dt_lfsck_layout_orphan_features;
} else if (seq >= FID_SEQ_NORMAL) {
/* object is part of the namespace, verify that it is a
* directory */
* \param obj - is the index object to parse
* \param rdpg - is the lu_rdpg descriptor associated with the transfer
* \param filler - is the callback function responsible for filling a lu_page
- * with key/record pairs in the format wanted by the caller
+ * with key/record pairs in the format wanted by the caller.
+ * If NULL, uses dt_index_page_build
* \param arg - is an opaq argument passed to the filler function
*
* \retval sum (in bytes) of all filled lu_pages
LASSERT(rdpg->rp_pages != NULL);
LASSERT(obj->do_index_ops != NULL);
+ if (filler == NULL)
+ filler = dt_index_page_build;
+
nob = rdpg->rp_count;
if (nob == 0)
RETURN(-EFAULT);
/* Iterate through index and fill containers from @rdpg */
iops = &obj->do_index_ops->dio_it;
LASSERT(iops != NULL);
- it = iops->init(env, obj, rdpg->rp_attrs, BYPASS_CAPA);
+ it = iops->init(env, obj, rdpg->rp_attrs);
if (IS_ERR(it))
RETURN(PTR_ERR(it));
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, LPU64"\n", result);
+ seq_printf(m, "%llu\n", result);
}
return rc;
}
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, LPU64"\n", result);
+ seq_printf(m, "%llu\n", result);
}
return rc;
}
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, LPU64"\n", result);
+ seq_printf(m, "%llu\n", result);
}
return rc;
}
int rc = dt_statfs(NULL, dt, &osfs);
if (rc == 0)
- seq_printf(m, LPU64"\n", osfs.os_files);
+ seq_printf(m, "%llu\n", osfs.os_files);
return rc;
}
EXPORT_SYMBOL(lprocfs_dt_filestotal_seq_show);
int rc = dt_statfs(NULL, dt, &osfs);
if (rc == 0)
- seq_printf(m, LPU64"\n", osfs.os_ffree);
+ seq_printf(m, "%llu\n", osfs.os_ffree);
return rc;
}
EXPORT_SYMBOL(lprocfs_dt_filesfree_seq_show);