return rc;
}
-int ll_md_real_close(struct inode *inode, int flags)
+int ll_md_real_close(struct inode *inode, fmode_t fmode)
{
- struct ll_inode_info *lli = ll_i2info(inode);
- struct obd_client_handle **och_p;
- struct obd_client_handle *och;
- __u64 *och_usecount;
- int rc = 0;
- ENTRY;
+ struct ll_inode_info *lli = ll_i2info(inode);
+ struct obd_client_handle **och_p;
+ struct obd_client_handle *och;
+ __u64 *och_usecount;
+ int rc = 0;
+ ENTRY;
- if (flags & FMODE_WRITE) {
- och_p = &lli->lli_mds_write_och;
- och_usecount = &lli->lli_open_fd_write_count;
- } else if (flags & FMODE_EXEC) {
- och_p = &lli->lli_mds_exec_och;
- och_usecount = &lli->lli_open_fd_exec_count;
- } else {
- LASSERT(flags & FMODE_READ);
- och_p = &lli->lli_mds_read_och;
- och_usecount = &lli->lli_open_fd_read_count;
- }
+ if (fmode & FMODE_WRITE) {
+ och_p = &lli->lli_mds_write_och;
+ och_usecount = &lli->lli_open_fd_write_count;
+ } else if (fmode & FMODE_EXEC) {
+ och_p = &lli->lli_mds_exec_och;
+ och_usecount = &lli->lli_open_fd_exec_count;
+ } else {
+ LASSERT(fmode & FMODE_READ);
+ och_p = &lli->lli_mds_read_och;
+ och_usecount = &lli->lli_open_fd_read_count;
+ }
mutex_lock(&lli->lli_och_mutex);
- if (*och_usecount) { /* There are still users of this handle, so
- skip freeing it. */
+ if (*och_usecount > 0) {
+ /* There are still users of this handle, so skip
+ * freeing it. */
mutex_unlock(&lli->lli_och_mutex);
- RETURN(0);
- }
- och=*och_p;
- *och_p = NULL;
+ RETURN(0);
+ }
+
+ och = *och_p;
+ *och_p = NULL;
mutex_unlock(&lli->lli_och_mutex);
- if (och) { /* There might be a race and somebody have freed this och
- already */
- rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp,
+ if (och != NULL) {
+ /* There might be a race and this handle may already
+ * be closed. */
+ rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp,
inode, och, NULL);
- }
+ }
- RETURN(rc);
+ RETURN(rc);
}
int ll_md_close(struct obd_export *md_exp, struct inode *inode,
{
struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
- struct cl_io *io;
- ssize_t result;
- ENTRY;
+ struct cl_io *io;
+ ssize_t result;
+ ENTRY;
+
+ CDEBUG(D_VFSTRACE, "file: %s, type: %d ppos: "LPU64", count: %zd\n",
+ file->f_dentry->d_name.name, iot, *ppos, count);
restart:
io = ccc_env_thread_io(env);
if ((iot == CIT_WRITE) &&
!(cio->cui_fd->fd_flags & LL_FILE_GROUP_LOCKED)) {
if (mutex_lock_interruptible(&lli->
- lli_write_mutex))
- GOTO(out, result = -ERESTARTSYS);
- write_mutex_locked = 1;
- } else if (iot == CIT_READ) {
- down_read(&lli->lli_trunc_sem);
- }
+ lli_write_mutex))
+ GOTO(out, result = -ERESTARTSYS);
+ write_mutex_locked = 1;
+ }
+ down_read(&lli->lli_trunc_sem);
break;
case IO_SENDFILE:
vio->u.sendfile.cui_actor = args->u.sendfile.via_actor;
LBUG();
}
result = cl_io_loop(env, io);
- if (write_mutex_locked)
- mutex_unlock(&lli->lli_write_mutex);
- else if (args->via_io_subtype == IO_NORMAL && iot == CIT_READ)
+ if (args->via_io_subtype == IO_NORMAL)
up_read(&lli->lli_trunc_sem);
+ if (write_mutex_locked)
+ mutex_unlock(&lli->lli_write_mutex);
} else {
/* cl_io_rw_init() handled IO */
result = io->ci_result;
fd->fd_write_failed = true;
}
}
+ CDEBUG(D_VFSTRACE, "iot: %d, result: %zd\n", iot, result);
return result;
}
}
op_data = ll_prep_md_op_data(NULL, inode, inode, NULL,
- 0, 0, LUSTRE_OPC_ANY, NULL);
+ 0, 0, LUSTRE_OPC_ANY, NULL);
if (IS_ERR(op_data)) {
mutex_unlock(&lli->lli_layout_mutex);
RETURN(PTR_ERR(op_data));