int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc);
extern int ll_setattr(struct dentry *de, struct iattr *attr);
-static int ll_create_objects(struct inode *inode, struct ll_inode_info *lli)
+int ll_create_objects(struct super_block *sb, obd_id id, uid_t uid, gid_t gid,
+ struct lov_stripe_md **lsmp)
{
struct obdo *oa;
int rc;
RETURN(-ENOMEM);
oa->o_mode = S_IFREG | 0600;
- oa->o_easize = ll_mds_easize(inode->i_sb);
- oa->o_id = inode->i_ino;
- oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE |
- OBD_MD_FLMODE | OBD_MD_FLEASIZE;
- rc = obd_create(ll_i2obdconn(inode), oa, &lli->lli_smd);
+ oa->o_easize = ll_mds_easize(sb);
+ oa->o_id = id;
+ oa->o_uid = uid;
+ oa->o_gid = gid;
+ oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE |
+ OBD_MD_FLEASIZE | OBD_MD_FLUID | OBD_MD_FLGID;
+ rc = obd_create(ll_s2obdconn(sb), oa, lsmp);
obdo_free(oa);
if (!rc)
- LASSERT(lli->lli_smd->lsm_object_id);
+ LASSERT((*lsmp)->lsm_object_id);
RETURN(rc);
}
down(&lli->lli_open_sem);
/* Check to see if we lost the race */
if (!lli->lli_smd)
- rc = ll_create_objects(inode, lli);
+ rc = ll_create_objects(inode->i_sb, inode->i_ino, 0, 0,
+ &lli->lli_smd);
up(&lli->lli_open_sem);
if (rc)
RETURN(rc);
oa->o_id = lsm->lsm_object_id;
oa->o_mode = S_IFREG;
- oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLSIZE;
+ oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLSIZE |
+ OBD_MD_FLBLOCKS;
rc = obd_open(ll_i2obdconn(inode), oa, lsm);
+ obdo_to_inode(inode, oa, oa->o_valid & (OBD_MD_FLSIZE|OBD_MD_FLBLOCKS));
obd_oa2handle(&fd->fd_osthandle, oa);
obdo_free(oa);
obdo_free(oa);
}
- if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK) ||
- sbi->ll_flags & LL_SBI_NOLCK) {
+ if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK) &&
+ !(sbi->ll_flags & LL_SBI_NOLCK)) {
OBD_ALLOC(lockhs, lsm->lsm_stripe_count * sizeof(*lockhs));
if (!lockhs)
GOTO(out_eof, retval = -ENOMEM);
lsm->lsm_mds_easize = size;
file->f_flags &= ~O_LOV_DELAY_CREATE;
- rc = ll_create_objects(inode, lli);
+ rc = ll_create_objects(inode->i_sb, inode->i_ino, 0, 0, &lsm);
if (rc)
OBD_FREE(lli->lli_smd, size);
else
}
body = lustre_msg_buf(request->rq_repmsg, 0);
if (lsm != NULL) {
- mds_md_size = ll_mds_easize(dir->i_sb);
- OBD_ALLOC(lmm, mds_md_size);
+ OBD_ALLOC(lmm, lsm->lsm_mds_easize);
lov_packmd(lmm, lsm);
lic.lic_lmm = lmm;
} else
* with d_instantiate().
*/
-static int ll_create(struct inode * dir, struct dentry * dentry, int mode)
+static int ll_create(struct inode *dir, struct dentry *dentry, int mode)
{
int err, rc = 0;
- struct obdo *oa = NULL;
struct inode *inode;
struct lov_stripe_md *lsm = NULL;
struct ll_inode_info *lli = NULL;
CHECK_MOUNT_EPOCH(dir);
if (dentry->d_it->it_disposition == 0) {
- int gid = current->fsgid;
-
- if (dir->i_mode & S_ISGID)
- gid = dir->i_gid;
-
- oa = obdo_alloc();
- if (!oa)
- RETURN(-ENOMEM);
-
- oa->o_mode = S_IFREG | 0600;
/* FIXME: we set the UID/GID fields to 0 for now, because it
* fixes a bug on the BA OSTs. We should really set
* them properly, and this needs to be revisited when
* we do proper credentials checking on the OST, and
* set the attributes on the OST in ll_inode_setattr().
- oa->o_uid = current->fsuid;
- oa->o_gid = gid;
- */
- oa->o_uid = 0;
- oa->o_gid = 0;
- oa->o_valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLUID |
- OBD_MD_FLGID;
- rc = obd_create(ll_i2obdconn(dir), oa, &lsm);
- CDEBUG(D_DENTRY, "name %s mode %o o_id "LPX64": rc = %d\n",
- dentry->d_name.name, mode, oa->o_id, rc);
+ * See also ll_file_open() and ll_lov_setstripe().
+ gid_t gid = current->fsgid;
+
+ if (dir->i_mode & S_ISGID)
+ gid = dir->i_gid;
+ rc = ll_create_objects(ll_i2obdconn(dir), 0, current->fsuid,
+ gid, &lsm);
+ */
+ rc = ll_create_objects(dir->i_sb, 0, 0, 0, &lsm);
+ CDEBUG(D_DENTRY, "name %*s mode %o: rc = %d\n",
+ dentry->d_name.len, dentry->d_name.name, mode, rc);
if (rc)
GOTO(out_free, rc);
}
if (IS_ERR(inode)) {
rc = PTR_ERR(inode);
- CERROR("error creating MDS object for id "LPX64": rc = %d\n",
- oa->o_id, rc);
+ CERROR("error creating MDS object for %*s: rc = %d\n",
+ dentry->d_name.len, dentry->d_name.name, rc);
GOTO(out_destroy, rc);
}
}
out_free:
- obdo_free(oa);
RETURN(rc);
out_destroy:
if (lsm) {
- if (!oa)
- oa = obdo_alloc();
- if (!oa)
- RETURN(-ENOMEM);
-
- oa->o_easize = ll_mds_easize(inode->i_sb);
- oa->o_valid |= OBD_MD_FLEASIZE;
- err = obd_destroy(ll_i2obdconn(dir), oa, lsm);
+ struct obdo *oa;
+ oa = obdo_alloc();
+ if (oa) {
+ oa->o_easize = lsm->lsm_mds_easize;
+ oa->o_id = lsm->lsm_object_id;
+ oa->o_valid |= OBD_MD_FLID | OBD_MD_FLEASIZE;
+ err = obd_destroy(ll_i2obdconn(dir), oa, lsm);
+ obdo_free(oa);
+ } else
+ err = -ENOMEM;
if (err)
CERROR("error uncreating objid "LPX64": err %d\n",
- oa->o_id, err);
+ lsm->lsm_object_id, err);
+ OBD_FREE(lsm, ll_ost_easize(dir->i_sb));
}
goto out_free;