struct dentry *dir, const char *name,
const struct lu_fid *fid,
const struct osd_inode_id *id,
- struct thandle *th)
+ handle_t *th)
{
struct inode *parent = dir->d_inode;
- struct osd_thandle *oh;
struct dentry *child;
struct ldiskfs_dir_entry_2 *de;
struct buffer_head *bh;
int rc;
ENTRY;
- oh = container_of(th, struct osd_thandle, ot_super);
- LASSERT(oh->ot_handle != NULL);
- LASSERT(oh->ot_handle->h_transaction != NULL);
+ LASSERT(th != NULL);
+ LASSERT(th->h_transaction != NULL);
child = &info->oti_child_dentry;
child->d_parent = dir;
* is still valid. Since it was referenced by an invalid entry,
* making it as invisible temporary may be not worse. OI scrub
* will process it later. */
- rc = ldiskfs_journal_get_write_access(oh->ot_handle, bh);
+ rc = ldiskfs_journal_get_write_access(th, bh);
if (rc != 0)
GOTO(out, rc);
de->inode = cpu_to_le32(id->oii_ino);
- rc = ldiskfs_journal_dirty_metadata(oh->ot_handle, bh);
+ rc = ldiskfs_journal_dirty_metadata(th, bh);
GOTO(out, rc);
static int osd_obj_del_entry(struct osd_thread_info *info,
struct osd_device *osd,
struct dentry *dird, char *name,
- struct thandle *th)
+ handle_t *th)
{
struct ldiskfs_dir_entry_2 *de;
struct buffer_head *bh;
- struct osd_thandle *oh;
struct dentry *child;
struct inode *dir = dird->d_inode;
int rc;
ENTRY;
- oh = container_of(th, struct osd_thandle, ot_super);
- LASSERT(oh->ot_handle != NULL);
- LASSERT(oh->ot_handle->h_transaction != NULL);
+ LASSERT(th != NULL);
+ LASSERT(th->h_transaction != NULL);
child = &info->oti_child_dentry;
rc = -ENOENT;
bh = osd_ldiskfs_find_entry(dir, child, &de, NULL);
if (bh) {
- rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh);
+ rc = ldiskfs_delete_entry(th, dir, de, bh);
brelse(bh);
}
mutex_unlock(&dir->i_mutex);
struct osd_device *osd,
struct dentry *dir, char *name,
const struct osd_inode_id *id,
- struct thandle *th)
+ handle_t *th)
{
- struct osd_thandle *oh;
struct dentry *child;
struct inode *inode;
int rc;
if (OBD_FAIL_CHECK(OBD_FAIL_OSD_COMPAT_NO_ENTRY))
RETURN(0);
- oh = container_of(th, struct osd_thandle, ot_super);
- LASSERT(oh->ot_handle != NULL);
- LASSERT(oh->ot_handle->h_transaction != NULL);
+ LASSERT(th != NULL);
+ LASSERT(th->h_transaction != NULL);
inode = &info->oti_inode;
inode->i_sb = osd_sb(osd);
ll_vfs_dq_init(dir->d_inode);
mutex_lock(&dir->d_inode->i_mutex);
- rc = osd_ldiskfs_add_entry(oh->ot_handle, child, inode, NULL);
+ rc = osd_ldiskfs_add_entry(th, child, inode, NULL);
mutex_unlock(&dir->d_inode->i_mutex);
RETURN(rc);
struct osd_device *osd,
const struct lu_fid *fid,
const struct osd_inode_id *id,
- struct thandle *th)
+ handle_t *th)
{
struct osd_obj_map *map;
struct osd_obj_seq *osd_seq;
}
int osd_obj_map_delete(struct osd_thread_info *info, struct osd_device *osd,
- const struct lu_fid *fid, struct thandle *th)
+ const struct lu_fid *fid, handle_t *th)
{
struct osd_obj_map *map;
struct osd_obj_seq *osd_seq;
struct osd_device *osd,
const struct lu_fid *fid,
const struct osd_inode_id *id,
- struct thandle *th)
+ handle_t *th)
{
struct osd_obj_seq *osd_seq;
struct dentry *d;
* So keep it there before we have suitable solution. */
brelse(bh);
mutex_unlock(&dir->i_mutex);
+ mutex_unlock(&src_parent->i_mutex);
+ ldiskfs_journal_stop(jh);
rc = -EEXIST;
/* If the src object has never been modified, then remove it. */
if (inode->i_size == 0 && inode->i_mode & S_ISUID &&
inode->i_mode & S_ISGID) {
- bh = osd_ldiskfs_find_entry(src_parent, src_child, &de,
- NULL);
- if (unlikely(bh == NULL)) {
- mutex_unlock(&src_parent->i_mutex);
- ldiskfs_journal_stop(jh);
- RETURN(0);
- }
-
- rc = ldiskfs_delete_entry(jh, src_parent, de, bh);
- brelse(bh);
- if (rc == 0) {
- drop_nlink(inode);
- ll_dirty_inode(inode, I_DIRTY_DATASYNC);
- }
+ rc = vfs_unlink(src_parent, src_child);
+ if (unlikely(rc == -ENOENT))
+ rc = 0;
}
- mutex_unlock(&src_parent->i_mutex);
- ldiskfs_journal_stop(jh);
RETURN(rc);
}
int osd_obj_spec_update(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th)
+ handle_t *th)
{
struct dentry *root;
char *name;
int osd_obj_spec_insert(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th)
+ handle_t *th)
{
struct dentry *root;
char *name;
* \retval 0, on success
*/
static int __osd_oi_insert(const struct lu_env *env, struct osd_object *obj,
- const struct lu_fid *fid, struct thandle *th)
+ const struct lu_fid *fid, struct thandle *th)
{
- struct osd_thread_info *info = osd_oti_get(env);
- struct osd_inode_id *id = &info->oti_id;
- struct osd_device *osd = osd_obj2dev(obj);
+ struct osd_thread_info *info = osd_oti_get(env);
+ struct osd_inode_id *id = &info->oti_id;
+ struct osd_device *osd = osd_obj2dev(obj);
+ struct osd_thandle *oh;
- LASSERT(obj->oo_inode != NULL);
+ LASSERT(obj->oo_inode != NULL);
+
+ oh = container_of0(th, struct osd_thandle, ot_super);
+ LASSERT(oh->ot_handle);
osd_id_gen(id, obj->oo_inode->i_ino, obj->oo_inode->i_generation);
- return osd_oi_insert(info, osd, fid, id, th, OI_CHECK_FLD);
+ return osd_oi_insert(info, osd, fid, id, oh->ot_handle, OI_CHECK_FLD);
}
int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd,
osd_trans_exec_op(env, th, OSD_OT_DESTROY);
- result = osd_oi_delete(osd_oti_get(env), osd, fid, th, OI_CHECK_FLD);
+ result = osd_oi_delete(osd_oti_get(env), osd, fid, oh->ot_handle,
+ OI_CHECK_FLD);
/* XXX: add to ext3 orphan list */
/* rc = ext3_orphan_add(handle_t *handle, struct inode *inode) */
const struct lu_fid *fid, struct osd_inode_id *id);
int osd_obj_map_insert(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th);
+ handle_t *th);
int osd_obj_map_delete(struct osd_thread_info *info, struct osd_device *osd,
- const struct lu_fid *fid, struct thandle *th);
+ const struct lu_fid *fid, handle_t *th);
int osd_obj_map_update(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th);
+ handle_t *th);
int osd_obj_map_recover(struct osd_thread_info *info, struct osd_device *osd,
struct inode *src_parent, struct dentry *src_child,
const struct lu_fid *fid);
const struct lu_fid *fid, struct osd_inode_id *id);
int osd_obj_spec_insert(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th);
+ handle_t *th);
int osd_obj_spec_update(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th);
+ handle_t *th);
void osd_scrub_file_reset(struct osd_scrub *scrub, __u8 *uuid, __u64 flags);
int osd_scrub_file_store(struct osd_scrub *scrub);
static int osd_oi_iam_refresh(struct osd_thread_info *oti, struct osd_oi *oi,
const struct dt_rec *rec, const struct dt_key *key,
- struct thandle *th, bool insert)
+ handle_t *th, bool insert)
{
struct iam_container *bag;
struct iam_path_descr *ipd;
- struct osd_thandle *oh;
int rc;
ENTRY;
if (unlikely(ipd == NULL))
RETURN(-ENOMEM);
- oh = container_of0(th, struct osd_thandle, ot_super);
- LASSERT(oh->ot_handle != NULL);
- LASSERT(oh->ot_handle->h_transaction != NULL);
+ LASSERT(th != NULL);
+ LASSERT(th->h_transaction != NULL);
if (insert)
- rc = iam_insert(oh->ot_handle, bag, (const struct iam_key *)key,
+ rc = iam_insert(th, bag, (const struct iam_key *)key,
(const struct iam_rec *)rec, ipd);
else
- rc = iam_update(oh->ot_handle, bag, (const struct iam_key *)key,
+ rc = iam_update(th, bag, (const struct iam_key *)key,
(const struct iam_rec *)rec, ipd);
osd_ipd_put(oti->oti_env, bag, ipd);
LINVRNT(osd_invariant(obj));
int osd_oi_insert(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th, enum oi_check_flags flags)
+ handle_t *th, enum oi_check_flags flags)
{
struct lu_fid *oi_fid = &info->oti_fid2;
struct osd_inode_id *oi_id = &info->oti_id2;
}
static int osd_oi_iam_delete(struct osd_thread_info *oti, struct osd_oi *oi,
- const struct dt_key *key, struct thandle *handle)
+ const struct dt_key *key, handle_t *th)
{
- struct iam_container *bag;
- struct iam_path_descr *ipd;
- struct osd_thandle *oh;
- int rc;
- ENTRY;
+ struct iam_container *bag;
+ struct iam_path_descr *ipd;
+ int rc;
+ ENTRY;
- LASSERT(oi);
+ LASSERT(oi);
LASSERT(oi->oi_inode);
ll_vfs_dq_init(oi->oi_inode);
- bag = &oi->oi_dir.od_container;
- ipd = osd_idx_ipd_get(oti->oti_env, bag);
- if (unlikely(ipd == NULL))
- RETURN(-ENOMEM);
+ bag = &oi->oi_dir.od_container;
+ ipd = osd_idx_ipd_get(oti->oti_env, bag);
+ if (unlikely(ipd == NULL))
+ RETURN(-ENOMEM);
- oh = container_of0(handle, struct osd_thandle, ot_super);
- LASSERT(oh->ot_handle != NULL);
- LASSERT(oh->ot_handle->h_transaction != NULL);
+ LASSERT(th != NULL);
+ LASSERT(th->h_transaction != NULL);
- rc = iam_delete(oh->ot_handle, bag, (const struct iam_key *)key, ipd);
- osd_ipd_put(oti->oti_env, bag, ipd);
- LINVRNT(osd_invariant(obj));
- RETURN(rc);
+ rc = iam_delete(th, bag, (const struct iam_key *)key, ipd);
+ osd_ipd_put(oti->oti_env, bag, ipd);
+ LINVRNT(osd_invariant(obj));
+ RETURN(rc);
}
int osd_oi_delete(struct osd_thread_info *info,
struct osd_device *osd, const struct lu_fid *fid,
- struct thandle *th, enum oi_check_flags flags)
+ handle_t *th, enum oi_check_flags flags)
{
struct lu_fid *oi_fid = &info->oti_fid2;
int osd_oi_update(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th, enum oi_check_flags flags)
+ handle_t *th, enum oi_check_flags flags)
{
struct lu_fid *oi_fid = &info->oti_fid2;
struct osd_inode_id *oi_id = &info->oti_id2;
/* struct rw_semaphore */
#include <linux/rwsem.h>
+#include <linux/jbd2.h>
#include <lustre_fid.h>
#include <lu_object.h>
#include <md_object.h>
struct lu_fid;
struct osd_thread_info;
struct lu_site;
-struct thandle;
struct dt_device;
struct osd_device;
enum oi_check_flags flags);
int osd_oi_insert(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th, enum oi_check_flags flags);
+ handle_t *th, enum oi_check_flags flags);
int osd_oi_delete(struct osd_thread_info *info,
struct osd_device *osd, const struct lu_fid *fid,
- struct thandle *th, enum oi_check_flags flags);
+ handle_t *th, enum oi_check_flags flags);
int osd_oi_update(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, const struct osd_inode_id *id,
- struct thandle *th, enum oi_check_flags flags);
+ handle_t *th, enum oi_check_flags flags);
int fid_is_on_ost(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, enum oi_check_flags flags);
int ops, bool force,
enum oi_check_flags flags)
{
- const struct lu_env *env = info->oti_env;
- struct thandle *th;
- struct osd_thandle *oh;
- int rc;
+ handle_t *th;
+ int rc;
ENTRY;
if (dev->od_scrub.os_file.sf_param & SP_DRYRUN && !force)
RETURN(0);
- th = dt_trans_create(env, &dev->od_dt_dev);
- if (IS_ERR(th))
- RETURN(PTR_ERR(th));
-
- oh = container_of0(th, struct osd_thandle, ot_super);
- LASSERT(oh->ot_handle == NULL);
+ /* DTO_INDEX_INSERT is enough for other two ops:
+ * delete/update, but save stack. */
+ th = ldiskfs_journal_start_sb(osd_sb(dev),
+ osd_dto_credits_noquota[DTO_INDEX_INSERT]);
+ if (IS_ERR(th)) {
+ rc = PTR_ERR(th);
+ CERROR("%s: fail to start trans for scrub %d: rc = %d\n",
+ osd_name(dev), ops, rc);
+ RETURN(rc);
+ }
switch (ops) {
case DTO_INDEX_UPDATE:
- osd_trans_declare_op(env, oh, OSD_OT_UPDATE,
- osd_dto_credits_noquota[DTO_INDEX_UPDATE]);
- rc = dt_trans_start_local(env, &dev->od_dt_dev, th);
- if (rc != 0)
- GOTO(stop, rc);
-
rc = osd_oi_update(info, dev, fid, id, th, flags);
if (unlikely(rc == -ENOENT)) {
/* Some unlink thread may removed the OI mapping. */
}
break;
case DTO_INDEX_INSERT:
- osd_trans_declare_op(env, oh, OSD_OT_INSERT,
- osd_dto_credits_noquota[DTO_INDEX_INSERT]);
- rc = dt_trans_start_local(env, &dev->od_dt_dev, th);
- if (rc != 0)
- GOTO(stop, rc);
-
rc = osd_oi_insert(info, dev, fid, id, th, flags);
if (unlikely(rc == -EEXIST)) {
rc = 1;
}
break;
case DTO_INDEX_DELETE:
- osd_trans_declare_op(env, oh, OSD_OT_DELETE,
- osd_dto_credits_noquota[DTO_INDEX_DELETE]);
- rc = dt_trans_start_local(env, &dev->od_dt_dev, th);
- if (rc != 0)
- GOTO(stop, rc);
-
rc = osd_oi_delete(info, dev, fid, th, flags);
if (rc == -ENOENT) {
/* It is normal that the unlink thread has removed the
break;
}
- GOTO(stop, rc);
-
-stop:
- dt_trans_stop(env, &dev->od_dt_dev, th);
+ ldiskfs_journal_stop(th);
return rc;
}