Esempio n. 1
0
static int osd_remove_oi_one(struct dentry *parent, const char *name,
			     int namelen)
{
	struct dentry *child;
	int rc;

	child = ll_lookup_one_len(name, parent, namelen);
	if (IS_ERR(child)) {
		rc = PTR_ERR(child);
	} else {
		rc = ll_vfs_unlink(parent->d_inode, child);
		dput(child);
	}

	return rc == -ENOENT ? 0 : rc;
}
Esempio n. 2
0
static int llog_lvfs_destroy(struct llog_handle *handle)
{
        struct dentry *fdentry;
        struct obdo *oa;
        struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd;
        char *dir;
        void *th;
        struct inode *inode;
        int rc, rc1;
        ENTRY;

        dir = MOUNT_CONFIGS_DIR;

        fdentry = handle->lgh_file->f_dentry;
        inode = fdentry->d_parent->d_inode;
        if (strcmp(fdentry->d_parent->d_name.name, dir) == 0) {
                struct lvfs_run_ctxt saved;
                struct vfsmount *mnt = mntget(handle->lgh_file->f_vfsmnt);

                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                dget(fdentry);
                rc = llog_lvfs_close(handle);

                if (rc == 0) {
                        LOCK_INODE_MUTEX_PARENT(inode);
                        rc = ll_vfs_unlink(inode, fdentry, mnt);
                        UNLOCK_INODE_MUTEX(inode);
                }
                mntput(mnt);

                dput(fdentry);
                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                RETURN(rc);
        }

        OBDO_ALLOC(oa);
        if (oa == NULL)
                RETURN(-ENOMEM);

        oa->o_id = handle->lgh_id.lgl_oid;
        oa->o_seq = handle->lgh_id.lgl_oseq;
        oa->o_generation = handle->lgh_id.lgl_ogen;
#undef o_generation
        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLGENER;

        rc = llog_lvfs_close(handle);
        if (rc)
                GOTO(out, rc);

        th = fsfilt_start_log(obd, inode, FSFILT_OP_UNLINK, NULL, 1);
        if (IS_ERR(th)) {
                CERROR("fsfilt_start failed: %ld\n", PTR_ERR(th));
                GOTO(out, rc = PTR_ERR(th));
        }

        rc = obd_destroy(handle->lgh_ctxt->loc_exp, oa, NULL, NULL, NULL, NULL);

        rc1 = fsfilt_commit(obd, inode, th, 0);
        if (rc == 0 && rc1 != 0)
                rc = rc1;
 out:
        OBDO_FREE(oa);
        RETURN(rc);
}
Esempio n. 3
0
static int llog_lvfs_destroy(const struct lu_env *env,
			     struct llog_handle *handle)
{
	struct dentry *fdentry;
	struct obdo *oa;
	struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd;
	char *dir;
	void *th;
	struct inode *inode;
	int rc, rc1;

	dir = MOUNT_CONFIGS_DIR;

	LASSERT(handle->lgh_file);
	fdentry = handle->lgh_file->f_dentry;
	inode = fdentry->d_parent->d_inode;
	if (strcmp(fdentry->d_parent->d_name.name, dir) == 0) {
		struct lvfs_run_ctxt saved;
		struct vfsmount *mnt = mntget(handle->lgh_file->f_vfsmnt);

		push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
		dget(fdentry);
		rc = llog_lvfs_close(env, handle);
		if (rc == 0) {
			mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
			rc = ll_vfs_unlink(inode, fdentry, mnt);
			mutex_unlock(&inode->i_mutex);
		}
		mntput(mnt);

		dput(fdentry);
		pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
		return rc;
	}

	OBDO_ALLOC(oa);
	if (oa == NULL)
		return -ENOMEM;

	oa->o_oi = handle->lgh_id.lgl_oi;
	oa->o_generation = handle->lgh_id.lgl_ogen;
#undef o_generation
	oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLGENER;

	rc = llog_lvfs_close(env, handle);
	if (rc)
		GOTO(out, rc);

	th = fsfilt_start_log(obd, inode, FSFILT_OP_UNLINK, NULL, 1);
	if (IS_ERR(th)) {
		CERROR("fsfilt_start failed: %ld\n", PTR_ERR(th));
		GOTO(out, rc = PTR_ERR(th));
	}

	rc = obd_destroy(NULL, handle->lgh_ctxt->loc_exp, oa,
			 NULL, NULL, NULL, NULL);

	rc1 = fsfilt_commit(obd, inode, th, 0);
	if (rc == 0 && rc1 != 0)
		rc = rc1;
 out:
	OBDO_FREE(oa);
	return rc;
}