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-3233 llite: use correct FID in ll_och_fill()
[fs/lustre-release.git]
/
lustre
/
llite
/
file.c
diff --git
a/lustre/llite/file.c
b/lustre/llite/file.c
index
a216652
..
ca7dd43
100644
(file)
--- a/
lustre/llite/file.c
+++ b/
lustre/llite/file.c
@@
-54,8
+54,12
@@
struct ll_file_data *ll_file_data_get(void)
{
struct ll_file_data *fd;
- OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, CFS_ALLOC_IO);
+ OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, __GFP_IO);
+ if (fd == NULL)
+ return NULL;
+
fd->fd_write_failed = false;
+
return fd;
}
@@
-439,24
+443,19
@@
void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch)
}
}
-static int ll_och_fill(struct obd_export *md_exp, struct l
l_inode_info *lli
,
-
struct lookup_intent *it,
struct obd_client_handle *och)
+static int ll_och_fill(struct obd_export *md_exp, struct l
ookup_intent *it
,
+ struct obd_client_handle *och)
{
- struct ptlrpc_request *req = it->d.lustre.it_data;
- struct mdt_body *body;
-
- LASSERT(och);
-
- body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
- LASSERT(body != NULL); /* reply already checked out */
+ struct ptlrpc_request *req = it->d.lustre.it_data;
+ struct mdt_body *body;
-
memcpy(&och->och_fh, &body->handle, sizeof(body->handle)
);
-
och->och_magic = OBD_CLIENT_HANDLE_MAGIC
;
-
och->och_fid = lli->lli_fid
;
-
och->och_flags = it->it_flags
;
-
ll_ioepoch_open(lli, body->ioepoch)
;
+
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY
);
+
och->och_fh = body->handle
;
+
och->och_fid = body->fid1
;
+
och->och_magic = OBD_CLIENT_HANDLE_MAGIC
;
+
och->och_flags = it->it_flags
;
-
return md_set_open_replay_data(md_exp, och, req);
+ return md_set_open_replay_data(md_exp, och, req);
}
int ll_local_open(struct file *file, struct lookup_intent *it,
@@
-475,21
+474,19
@@
int ll_local_open(struct file *file, struct lookup_intent *it,
struct mdt_body *body;
int rc;
-
rc = ll_och_fill(ll_i2sbi(inode)->ll_md_exp, lli
, it, och);
-
if (rc
)
-
RETURN(rc);
+
rc = ll_och_fill(ll_i2sbi(inode)->ll_md_exp
, it, och);
+
if (rc != 0
)
+ RETURN(rc);
- body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
- if ((it->it_flags & FMODE_WRITE) &&
- (body->valid & OBD_MD_FLSIZE))
- CDEBUG(D_INODE, "Epoch "LPU64" opened on "DFID"\n",
- lli->lli_ioepoch, PFID(&lli->lli_fid));
- }
+ body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
+ ll_ioepoch_open(lli, body->ioepoch);
+ }
+
+ LUSTRE_FPRIVATE(file) = fd;
+ ll_readahead_init(inode, &fd->fd_ras);
+ fd->fd_omode = it->it_flags;
- LUSTRE_FPRIVATE(file) = fd;
- ll_readahead_init(inode, &fd->fd_ras);
- fd->fd_omode = it->it_flags;
- RETURN(0);
+ RETURN(0);
}
/* Open a file, and (for the very first open) create objects on the OSTs at
@@
-522,12
+519,12
@@
int ll_file_open(struct inode *inode, struct file *file)
it = file->private_data; /* XXX: compat macro */
file->private_data = NULL; /* prevent ll_local_open assertion */
-
fd = ll_file_data_get();
-
if (fd == NULL)
-
GOTO(out_och_free
, rc = -ENOMEM);
+ fd = ll_file_data_get();
+ if (fd == NULL)
+
GOTO(out_openerr
, rc = -ENOMEM);
-
fd->fd_file = file;
-
if (S_ISDIR(inode->i_mode)) {
+ fd->fd_file = file;
+ if (S_ISDIR(inode->i_mode)) {
spin_lock(&lli->lli_sa_lock);
if (lli->lli_opendir_key == NULL && lli->lli_sai == NULL &&
lli->lli_opendir_pid == 0) {
@@
-536,7
+533,7
@@
int ll_file_open(struct inode *inode, struct file *file)
opendir_set = 1;
}
spin_unlock(&lli->lli_sa_lock);
-
}
+ }
if (inode->i_sb->s_root == file->f_dentry) {
LUSTRE_FPRIVATE(file) = fd;
@@
-923,7
+920,7
@@
out:
cl_io_fini(env, io);
/* If any bit been read/written (result != 0), we just return
* short read/write instead of restart io. */
- if (
result == 0
&& io->ci_need_restart) {
+ if (
(result == 0 || result == -ENODATA)
&& io->ci_need_restart) {
CDEBUG(D_VFSTRACE, "Restart %s on %s from %lld, count:%zd\n",
iot == CIT_READ ? "read" : "write",
file->f_dentry->d_name.name, *ppos, count);
@@
-1202,35
+1199,6
@@
static ssize_t ll_file_write(struct file *file, const char *buf, size_t count,
}
#endif
-
-#ifdef HAVE_KERNEL_SENDFILE
-/*
- * Send file content (through pagecache) somewhere with helper
- */
-static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,size_t count,
- read_actor_t actor, void *target)
-{
- struct lu_env *env;
- struct vvp_io_args *args;
- ssize_t result;
- int refcheck;
- ENTRY;
-
- env = cl_env_get(&refcheck);
- if (IS_ERR(env))
- RETURN(PTR_ERR(env));
-
- args = vvp_env_args(env, IO_SENDFILE);
- args->u.sendfile.via_target = target;
- args->u.sendfile.via_actor = actor;
-
- result = ll_file_io_generic(env, args, in_file, CIT_READ, ppos, count);
- cl_env_put(env, &refcheck);
- RETURN(result);
-}
-#endif
-
-#ifdef HAVE_KERNEL_SPLICE_READ
/*
* Send file content (through pagecache) somewhere with helper
*/
@@
-1256,7
+1224,6
@@
static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos,
cl_env_put(env, &refcheck);
RETURN(result);
}
-#endif
static int ll_lov_recreate(struct inode *inode, struct ost_id *oi,
obd_count ost_idx)
@@
-1274,7
+1241,7
@@
static int ll_lov_recreate(struct inode *inode, struct ost_id *oi,
RETURN(-ENOMEM);
lsm = ccc_inode_lsm_get(inode);
-
if (lsm == NULL
)
+
if (!lsm_has_objects(lsm)
)
GOTO(out, rc = -ENOENT);
lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) *
@@
-1430,6
+1397,12
@@
int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
* passing it to userspace.
*/
if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) {
+ int stripe_count;
+
+ stripe_count = le16_to_cpu(lmm->lmm_stripe_count);
+ if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED)
+ stripe_count = 0;
+
/* if function called for directory - we should
* avoid swab not existent lsm objects */
if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) {
@@
-1437,13
+1410,13
@@
int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
if (S_ISREG(body->mode))
lustre_swab_lov_user_md_objects(
((struct lov_user_md_v1 *)lmm)->lmm_objects,
-
((struct lov_user_md_v1 *)lmm)->lmm_
stripe_count);
+ stripe_count);
} else if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V3)) {
lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm);
if (S_ISREG(body->mode))
lustre_swab_lov_user_md_objects(
((struct lov_user_md_v3 *)lmm)->lmm_objects,
-
((struct lov_user_md_v3 *)lmm)->lmm_
stripe_count);
+ stripe_count);
}
}
@@
-1640,8
+1613,7
@@
int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it)
if (!och)
GOTO(out, rc = -ENOMEM);
- ll_och_fill(ll_i2sbi(inode)->ll_md_exp,
- ll_i2info(inode), it, och);
+ ll_och_fill(ll_i2sbi(inode)->ll_md_exp, it, och);
rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp,
inode, och);
@@
-1829,20
+1801,18
@@
int ll_data_version(struct inode *inode, __u64 *data_version,
/* If no stripe, we consider version is 0. */
lsm = ccc_inode_lsm_get(inode);
- if (
lsm == NULL
) {
+ if (
!lsm_has_objects(lsm)
) {
*data_version = 0;
CDEBUG(D_INODE, "No object for inode\n");
-
RETURN(
0);
+
GOTO(out, rc =
0);
}
OBD_ALLOC_PTR(obdo);
- if (obdo == NULL) {
- ccc_inode_lsm_put(inode, lsm);
- RETURN(-ENOMEM);
- }
+ if (obdo == NULL)
+ GOTO(out, rc = -ENOMEM);
rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, NULL, obdo, 0, extent_lock);
- if (
!rc
) {
+ if (
rc == 0
) {
if (!(obdo->o_valid & OBD_MD_FLDATAVERSION))
rc = -EOPNOTSUPP;
else
@@
-1850,8
+1820,9
@@
int ll_data_version(struct inode *inode, __u64 *data_version,
}
OBD_FREE_PTR(obdo);
+ EXIT;
+out:
ccc_inode_lsm_put(inode, lsm);
-
RETURN(rc);
}
@@
-1882,8
+1853,8
@@
static int ll_swap_layouts(struct file *file1, struct file *file2,
if (!S_ISREG(llss->inode2->i_mode))
GOTO(free, rc = -EINVAL);
- if (
ll_permission(llss->inode1, MAY_WRITE, NULL
) ||
-
ll_permission(llss->inode2, MAY_WRITE, NULL
))
+ if (
inode_permission(llss->inode1, MAY_WRITE
) ||
+
inode_permission(llss->inode2, MAY_WRITE
))
GOTO(free, rc = -EPERM);
if (llss->inode2->i_sb != llss->inode1->i_sb)
@@
-1963,12
+1934,12
@@
static int ll_swap_layouts(struct file *file1, struct file *file2,
rc = -ENOMEM;
op_data = ll_prep_md_op_data(NULL, llss->inode1, llss->inode2, NULL, 0,
0, LUSTRE_OPC_ANY, &msl);
- if (
op_data != NULL) {
- rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS,
- ll_i2mdexp(llss->inode1),
- sizeof(*op_data), op_data, NULL);
-
ll_finish_md_op_data(op_data
);
- }
+ if (
IS_ERR(op_data))
+ GOTO(free, rc = PTR_ERR(op_data));
+
+ rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS, ll_i2mdexp(llss->inode1),
+
sizeof(*op_data), op_data, NULL
);
+ ll_finish_md_op_data(op_data);
putgl:
if (gid != 0) {
@@
-2065,7
+2036,7
@@
long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct file *file2;
struct lustre_swap_layouts lsl;
- if (c
fs_c
opy_from_user(&lsl, (char *)arg,
+ if (copy_from_user(&lsl, (char *)arg,
sizeof(struct lustre_swap_layouts)))
RETURN(-EFAULT);
@@
-2162,9
+2133,9
@@
long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
LUSTRE_OPC_ANY, hus);
- if (
op_data == NULL
) {
+ if (
IS_ERR(op_data)
) {
OBD_FREE_PTR(hus);
- RETURN(
-ENOMEM
);
+ RETURN(
PTR_ERR(op_data)
);
}
rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data),
@@
-2200,9
+2171,9
@@
long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
LUSTRE_OPC_ANY, hss);
- if (
op_data == NULL
) {
+ if (
IS_ERR(op_data)
) {
OBD_FREE_PTR(hss);
- RETURN(
-ENOMEM
);
+ RETURN(
PTR_ERR(op_data)
);
}
rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data),
@@
-2224,15
+2195,15
@@
long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
LUSTRE_OPC_ANY, hca);
- if (
op_data == NULL
) {
+ if (
IS_ERR(op_data)
) {
OBD_FREE_PTR(hca);
- RETURN(
-ENOMEM
);
+ RETURN(
PTR_ERR(op_data)
);
}
rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data),
op_data, NULL);
- if (c
fs_c
opy_to_user((char *)arg, hca, sizeof(*hca)))
+ if (copy_to_user((char *)arg, hca, sizeof(*hca)))
rc = -EFAULT;
ll_finish_md_op_data(op_data);
@@
-2502,18
+2473,20
@@
int ll_fsync(struct file *file, struct dentry *dentry, int datasync)
int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
{
- struct inode *inode = file->f_dentry->d_inode;
- struct ll_sb_info *sbi = ll_i2sbi(inode);
- struct ldlm_enqueue_info einfo = { .ei_type = LDLM_FLOCK,
- .ei_cb_cp =ldlm_flock_completion_ast,
- .ei_cbdata = file_lock };
- struct md_op_data *op_data;
- struct lustre_handle lockh = {0};
- ldlm_policy_data_t flock = {{0}};
- int flags = 0;
- int rc;
+ struct inode *inode = file->f_dentry->d_inode;
+ struct ll_sb_info *sbi = ll_i2sbi(inode);
+ struct ldlm_enqueue_info einfo = {
+ .ei_type = LDLM_FLOCK,
+ .ei_cb_cp = ldlm_flock_completion_ast,
+ .ei_cbdata = file_lock,
+ };
+ struct md_op_data *op_data;
+ struct lustre_handle lockh = {0};
+ ldlm_policy_data_t flock = {{0}};
+ int flags = 0;
+ int rc;
int rc2 = 0;
-
ENTRY;
+ ENTRY;
CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu file_lock=%p\n",
inode->i_ino, file_lock);
@@
-2663,11
+2636,11
@@
int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode)
CDEBUG(D_INFO, "trying to match res "DFID" mode %s\n", PFID(fid),
ldlm_lockname[mode]);
-
flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK;
-
for (i = 0; i <
MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) {
-
policy.l_inodebits.bits = *bits & (1 << i);
-
if (policy.l_inodebits.bits == 0)
-
continue;
+ flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK;
+
for (i = 0; i <=
MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) {
+ policy.l_inodebits.bits = *bits & (1 << i);
+ if (policy.l_inodebits.bits == 0)
+ continue;
if (md_lock_match(ll_i2mdexp(inode), flags, fid, LDLM_IBITS,
&policy, mode, &lockh)) {
@@
-2820,13
+2793,13
@@
out:
}
int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
-
__u64 ibits)
+ __u64 ibits)
{
-
struct inode
*inode = dentry->d_inode;
-
int
rc;
-
ENTRY;
+
struct inode
*inode = dentry->d_inode;
+
int
rc;
+ ENTRY;
-
rc = __ll_inode_revalidate_it(dentry, it, ibits);
+ rc = __ll_inode_revalidate_it(dentry, it, ibits);
if (rc != 0)
RETURN(rc);
@@
-2836,9
+2809,17
@@
int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
LTIME_S(inode->i_mtime) = ll_i2info(inode)->lli_lvb.lvb_mtime;
LTIME_S(inode->i_ctime) = ll_i2info(inode)->lli_lvb.lvb_ctime;
} else {
- rc = ll_glimpse_size(inode);
+ /* In case of restore, the MDT has the right size and has
+ * already send it back without granting the layout lock,
+ * inode is up-to-date so glimpse is useless.
+ * Also to glimpse we need the layout, in case of a running
+ * restore the MDT holds the layout lock so the glimpse will
+ * block up to the end of restore (getattr will block)
+ */
+ if (!(ll_i2info(inode)->lli_flags & LLIF_FILE_RESTORING))
+ rc = ll_glimpse_size(inode);
}
-
RETURN(rc);
+ RETURN(rc);
}
int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
@@
-3032,12
+3013,7
@@
struct file_operations ll_file_operations = {
.release = ll_file_release,
.mmap = ll_file_mmap,
.llseek = ll_file_seek,
-#ifdef HAVE_KERNEL_SENDFILE
- .sendfile = ll_file_sendfile,
-#endif
-#ifdef HAVE_KERNEL_SPLICE_READ
.splice_read = ll_file_splice_read,
-#endif
.fsync = ll_fsync,
.flush = ll_flush
};
@@
-3052,12
+3028,7
@@
struct file_operations ll_file_operations_flock = {
.release = ll_file_release,
.mmap = ll_file_mmap,
.llseek = ll_file_seek,
-#ifdef HAVE_KERNEL_SENDFILE
- .sendfile = ll_file_sendfile,
-#endif
-#ifdef HAVE_KERNEL_SPLICE_READ
.splice_read = ll_file_splice_read,
-#endif
.fsync = ll_fsync,
.flush = ll_flush,
.flock = ll_file_flock,
@@
-3075,12
+3046,7
@@
struct file_operations ll_file_operations_noflock = {
.release = ll_file_release,
.mmap = ll_file_mmap,
.llseek = ll_file_seek,
-#ifdef HAVE_KERNEL_SENDFILE
- .sendfile = ll_file_sendfile,
-#endif
-#ifdef HAVE_KERNEL_SPLICE_READ
.splice_read = ll_file_splice_read,
-#endif
.fsync = ll_fsync,
.flush = ll_flush,
.flock = ll_file_noflock,
@@
-3251,7
+3217,11
@@
static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
int rc;
ENTRY;
- if (lock->l_lvb_data != NULL)
+ CDEBUG(D_INODE, DFID" LVB_READY=%d l_lvb_data=%p l_lvb_len=%d\n",
+ PFID(ll_inode2fid(inode)), !!(lock->l_flags & LDLM_FL_LVB_READY),
+ lock->l_lvb_data, lock->l_lvb_len);
+
+ if ((lock->l_lvb_data != NULL) && (lock->l_flags & LDLM_FL_LVB_READY))
RETURN(0);
/* if layout lock was granted right away, the layout is returned
@@
-3287,15
+3257,13
@@
static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
memcpy(lvbdata, lmm, lmmsize);
lock_res_and_lock(lock);
- if (lock->l_lvb_data
== NULL) {
-
lock->l_lvb_data = lvbdata
;
- lock->l_lvb_len = lmmsize;
-
lvbdata = NULL
;
- }
+ if (lock->l_lvb_data
!= NULL)
+
OBD_FREE_LARGE(lock->l_lvb_data, lock->l_lvb_len)
;
+
+
lock->l_lvb_data = lvbdata
;
+ lock->l_lvb_len = lmmsize;
unlock_res_and_lock(lock);
- if (lvbdata != NULL)
- OBD_FREE_LARGE(lvbdata, lmmsize);
EXIT;
out:
@@
-3327,7
+3295,7
@@
static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode,
LASSERT(ldlm_has_layout(lock));
LDLM_DEBUG(lock, "File %p/"DFID" being reconfigured: %d.\n",
- inode, PFID(&lli->lli_fid), reconf);
+
inode, PFID(&lli->lli_fid), reconf);
/* in case this is a caching lock and reinstate with new inode */
md_set_lock_data(sbi->ll_md_exp, &lockh->cookie, inode, NULL);
@@
-3337,6
+3305,7
@@
static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode,
unlock_res_and_lock(lock);
/* checking lvb_ready is racy but this is okay. The worst case is
* that multi processes may configure the file on the same time. */
+
if (lvb_ready || !reconf) {
rc = -ENODATA;
if (lvb_ready) {
@@
-3433,11
+3402,12
@@
int ll_layout_refresh(struct inode *inode, __u32 *gen)
struct lookup_intent it;
struct lustre_handle lockh;
ldlm_mode_t mode;
- struct ldlm_enqueue_info einfo = { .ei_type = LDLM_IBITS,
- .ei_mode = LCK_CR,
- .ei_cb_bl = ll_md_blocking_ast,
- .ei_cb_cp = ldlm_completion_ast,
- .ei_cbdata = NULL };
+ struct ldlm_enqueue_info einfo = {
+ .ei_type = LDLM_IBITS,
+ .ei_mode = LCK_CR,
+ .ei_cb_bl = ll_md_blocking_ast,
+ .ei_cb_cp = ldlm_completion_ast,
+ };
int rc;
ENTRY;
@@
-3515,3
+3485,32
@@
again:
RETURN(rc);
}
+
+/**
+ * This function send a restore request to the MDT
+ */
+int ll_layout_restore(struct inode *inode)
+{
+ struct hsm_user_request *hur;
+ int len, rc;
+ ENTRY;
+
+ len = sizeof(struct hsm_user_request) +
+ sizeof(struct hsm_user_item);
+ OBD_ALLOC(hur, len);
+ if (hur == NULL)
+ RETURN(-ENOMEM);
+
+ hur->hur_request.hr_action = HUA_RESTORE;
+ hur->hur_request.hr_archive_id = 0;
+ hur->hur_request.hr_flags = 0;
+ memcpy(&hur->hur_user_item[0].hui_fid, &ll_i2info(inode)->lli_fid,
+ sizeof(hur->hur_user_item[0].hui_fid));
+ hur->hur_user_item[0].hui_extent.length = -1;
+ hur->hur_request.hr_itemcount = 1;
+ rc = obd_iocontrol(LL_IOC_HSM_REQUEST, cl_i2sbi(inode)->ll_md_exp,
+ len, hur, NULL);
+ OBD_FREE(hur, len);
+ RETURN(rc);
+}
+