}
}
-static int ll_och_fill(struct obd_export *md_exp, struct ll_inode_info *lli,
- struct lookup_intent *it, struct obd_client_handle *och)
+static int ll_och_fill(struct obd_export *md_exp, struct lookup_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,
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
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);
}
#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
*/
cl_env_put(env, &refcheck);
RETURN(result);
}
-#endif
static int ll_lov_recreate(struct inode *inode, struct ost_id *oi,
obd_count ost_idx)
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);
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)
}
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);
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,
.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
};
.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,
.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,
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) {
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);
+}
+