static struct ll_file_data *ll_file_data_get(void)
{
- struct ll_file_data *fd;
+ struct ll_file_data *lfd;
- OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, GFP_NOFS);
- if (fd == NULL)
+ OBD_SLAB_ALLOC_PTR_GFP(lfd, ll_file_data_slab, GFP_NOFS);
+ if (lfd == NULL)
return NULL;
- fd->fd_write_failed = false;
- pcc_file_init(&fd->fd_pcc_file);
+ lfd->fd_write_failed = false;
+ pcc_file_init(&lfd->fd_pcc_file);
- return fd;
+ return lfd;
}
-static void ll_file_data_put(struct ll_file_data *fd)
+static void ll_file_data_put(struct ll_file_data *lfd)
{
- if (fd != NULL)
- OBD_SLAB_FREE_PTR(fd, ll_file_data_slab);
+ if (lfd != NULL)
+ OBD_SLAB_FREE_PTR(lfd, ll_file_data_slab);
}
/* Packs all the attributes into @op_data for the CLOSE rpc. */
op_data->op_attr_flags = ll_inode2ext_flags(inode);
op_data->op_open_handle = och->och_open_handle;
- if (och->och_flags & FMODE_WRITE &&
+ if (och->och_flags & MDS_FMODE_WRITE &&
test_and_clear_bit(LLIF_DATA_MODIFIED,
&ll_i2info(inode)->lli_flags))
/* For HSM: if inode data has been modified, pack it so that
.l_inodebits = { MDS_INODELOCK_OPEN },
};
__u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct ll_inode_info *lli = ll_i2info(inode);
struct lustre_handle lockh;
enum ldlm_mode lockmode;
ENTRY;
/* clear group lock, if present */
- if (unlikely(fd->fd_flags & LL_FILE_GROUP_LOCKED))
- ll_put_grouplock(inode, file, fd->fd_grouplock.lg_gid);
+ if (unlikely(lfd->fd_flags & LL_FILE_GROUP_LOCKED))
+ ll_put_grouplock(inode, file, lfd->fd_grouplock.lg_gid);
mutex_lock(&lli->lli_och_mutex);
- if (fd->fd_lease_och != NULL) {
+ if (lfd->fd_lease_och != NULL) {
bool lease_broken;
struct obd_client_handle *lease_och;
- lease_och = fd->fd_lease_och;
- fd->fd_lease_och = NULL;
+ lease_och = lfd->fd_lease_och;
+ lfd->fd_lease_och = NULL;
mutex_unlock(&lli->lli_och_mutex);
/* Usually the lease is not released when the
PFID(&lli->lli_fid), rc, lease_broken);
}
- if (fd->fd_och != NULL) {
+ if (lfd->fd_och != NULL) {
struct obd_client_handle *och;
- och = fd->fd_och;
- fd->fd_och = NULL;
+ och = lfd->fd_och;
+ lfd->fd_och = NULL;
mutex_unlock(&lli->lli_och_mutex);
rc = ll_close_inode_openhandle(inode, och, 0, NULL);
/* Let's see if we have good enough OPEN lock on the file and if we can
* skip talking to MDS
*/
- if (fd->fd_omode & FMODE_WRITE) {
+ if (lfd->fd_omode & FMODE_WRITE) {
lockmode = LCK_CW;
LASSERT(lli->lli_open_fd_write_count);
lli->lli_open_fd_write_count--;
- } else if (fd->fd_omode & FMODE_EXEC) {
+ } else if (lfd->fd_omode & FMODE_EXEC) {
lockmode = LCK_PR;
LASSERT(lli->lli_open_fd_exec_count);
lli->lli_open_fd_exec_count--;
if ((lockmode == LCK_CW && inode->i_mode & 0111) ||
!md_lock_match(ll_i2mdexp(inode), flags, ll_inode2fid(inode),
LDLM_IBITS, &policy, lockmode, &lockh))
- rc = ll_md_real_close(inode, fd->fd_omode);
+ rc = ll_md_real_close(inode, lfd->fd_omode);
out:
file->private_data = NULL;
- ll_file_data_put(fd);
+ ll_file_data_put(lfd);
RETURN(rc);
}
*/
int ll_file_release(struct inode *inode, struct file *file)
{
- struct ll_file_data *fd;
+ struct ll_file_data *lfd;
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ll_inode_info *lli = ll_i2info(inode);
ktime_t kstart = ktime_get();
file_dentry(file)->d_name.name,
PFID(ll_inode2fid(file_inode(file))), inode, file->f_flags);
- fd = file->private_data;
- LASSERT(fd != NULL);
+ lfd = file->private_data;
+ LASSERT(lfd != NULL);
/* The last ref on @file, maybe not the the owner pid of statahead,
* because parent and child process can share the same file handle.
*/
if (S_ISDIR(inode->i_mode) &&
- (lli->lli_opendir_key == fd || fd->fd_sai))
- ll_deauthorize_statahead(inode, fd);
+ (lli->lli_opendir_key == lfd || lfd->fd_sai))
+ ll_deauthorize_statahead(inode, lfd);
if (is_root_inode(inode)) {
file->private_data = NULL;
- ll_file_data_put(fd);
+ ll_file_data_put(lfd);
GOTO(out, rc = 0);
}
}
static int ll_local_open(struct file *file, struct lookup_intent *it,
- struct ll_file_data *fd, struct obd_client_handle *och)
+ struct ll_file_data *lfd,
+ struct obd_client_handle *och)
{
struct inode *inode = file_inode(file);
ENTRY;
LASSERT(!file->private_data);
- LASSERT(fd != NULL);
+ LASSERT(lfd != NULL);
if (och) {
int rc;
RETURN(rc);
}
- file->private_data = fd;
- ll_readahead_init(inode, &fd->fd_ras);
- fd->fd_omode = it->it_open_flags & (FMODE_READ | FMODE_WRITE |
- FMODE_EXEC);
+ file->private_data = lfd;
+ ll_readahead_init(inode, &lfd->fd_ras);
+ lfd->fd_omode = it->it_open_flags & (FMODE_READ | FMODE_WRITE |
+ FMODE_EXEC);
RETURN(0);
}
.it_open_flags = file->f_flags };
struct obd_client_handle **och_p = NULL;
__u64 *och_usecount = NULL;
- struct ll_file_data *fd;
+ struct ll_file_data *lfd;
ktime_t kstart = ktime_get();
int rc = 0;
}
}
- fd = ll_file_data_get();
- if (fd == NULL)
+ lfd = ll_file_data_get();
+ if (lfd == NULL)
GOTO(out_nofiledata, rc = -ENOMEM);
- fd->fd_file = file;
+ lfd->fd_file = file;
if (S_ISDIR(inode->i_mode))
- ll_authorize_statahead(inode, fd);
+ ll_authorize_statahead(inode, lfd);
ll_track_file_opens(inode);
if (is_root_inode(inode)) {
- file->private_data = fd;
+ file->private_data = lfd;
RETURN(0);
}
}
(*och_usecount)++;
- rc = ll_local_open(file, it, fd, NULL);
+ rc = ll_local_open(file, it, lfd, NULL);
if (rc) {
(*och_usecount)--;
mutex_unlock(&lli->lli_och_mutex);
"inode %px: disposition %x, status %d\n", inode,
it_disposition(it, ~0), it->it_status);
- rc = ll_local_open(file, it, fd, *och_p);
+ rc = ll_local_open(file, it, lfd, *och_p);
if (rc)
GOTO(out_och_free, rc);
}
GOTO(out_och_free, rc);
}
- fd = NULL;
+ lfd = NULL;
/* Must do this outside lli_och_mutex lock to prevent deadlock where
* different kind of OPEN lock for this same inode gets cancelled by
mutex_unlock(&lli->lli_och_mutex);
out_openerr:
- if (lli->lli_opendir_key == fd)
- ll_deauthorize_statahead(inode, fd);
+ if (lli->lli_opendir_key == lfd)
+ ll_deauthorize_statahead(inode, lfd);
- if (fd != NULL)
- ll_file_data_put(fd);
+ if (lfd != NULL)
+ ll_file_data_put(lfd);
} else {
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN,
ktime_us_delta(ktime_get(), kstart));
struct lustre_handle *old_open_handle)
{
struct ll_inode_info *lli = ll_i2info(inode);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct obd_client_handle **och_p;
__u64 *och_usecount;
int rc = 0;
ENTRY;
/* Get the openhandle of the file */
mutex_lock(&lli->lli_och_mutex);
- if (fd->fd_lease_och != NULL)
+ if (lfd->fd_lease_och != NULL)
GOTO(out_unlock, rc = -EBUSY);
- if (fd->fd_och == NULL) {
+ if (lfd->fd_och == NULL) {
if (file->f_mode & FMODE_WRITE) {
LASSERT(lli->lli_mds_write_och != NULL);
och_p = &lli->lli_mds_write_och;
if (*och_usecount > 1)
GOTO(out_unlock, rc = -EBUSY);
- fd->fd_och = *och_p;
+ lfd->fd_och = *och_p;
*och_usecount = 0;
*och_p = NULL;
}
- *old_open_handle = fd->fd_och->och_open_handle;
+ *old_open_handle = lfd->fd_och->och_open_handle;
EXIT;
out_unlock:
static int ll_lease_och_release(struct inode *inode, struct file *file)
{
struct ll_inode_info *lli = ll_i2info(inode);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct obd_client_handle **och_p;
struct obd_client_handle *old_och = NULL;
__u64 *och_usecount;
* and close fd_och.
*/
if (*och_p != NULL) {
- old_och = fd->fd_och;
+ old_och = lfd->fd_och;
(*och_usecount)++;
} else {
- *och_p = fd->fd_och;
+ *och_p = lfd->fd_och;
*och_usecount = 1;
}
- fd->fd_och = NULL;
+ lfd->fd_och = NULL;
mutex_unlock(&lli->lli_och_mutex);
if (old_och != NULL)
*/
void ll_io_set_mirror(struct cl_io *io, const struct file *file)
{
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
/* clear layout version for generic(non-resync) I/O in case it carries
* stale layout version due to I/O restart
/* FLR: disable non-delay for designated mirror I/O because obviously
* only one mirror is available
*/
- if (fd->fd_designated_mirror > 0) {
+ if (lfd->fd_designated_mirror > 0) {
io->ci_ndelay = 0;
- io->ci_designated_mirror = fd->fd_designated_mirror;
- io->ci_layout_version = fd->fd_layout_version;
+ io->ci_designated_mirror = lfd->fd_designated_mirror;
+ io->ci_layout_version = lfd->fd_layout_version;
}
CDEBUG(D_VFSTRACE, "%s: desiginated mirror: %d\n",
struct vvp_io_args *args)
{
struct inode *inode = file_inode(file);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
int flags = vvp_io_args_flags(file, args);
io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK;
- io->ci_lock_no_expand = fd->ll_lock_no_expand;
+ io->ci_lock_no_expand = lfd->ll_lock_no_expand;
if (iot == CIT_WRITE) {
io->u.ci_wr.wr_append = iocb_ki_flags_check(flags, APPEND);
loff_t *ppos, size_t bytes)
{
struct inode *inode = file_inode(file);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct vvp_io *vio = vvp_env_io(env);
if (result > 0) {
ll_stats_ops_tally(ll_i2sbi(inode),
LPROC_LL_WRITE_BYTES, result);
- fd->fd_write_failed = false;
+ lfd->fd_write_failed = false;
} else if (result == 0 && rc == 0) {
rc = io->ci_result;
if (rc < 0)
- fd->fd_write_failed = true;
+ lfd->fd_write_failed = true;
else
- fd->fd_write_failed = false;
+ lfd->fd_write_failed = false;
} else if (rc != -ERESTARTSYS) {
- fd->fd_write_failed = true;
+ lfd->fd_write_failed = true;
}
}
{
struct ll_inode_info *lli = ll_i2info(inode);
struct cl_object *obj = lli->lli_clob;
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct ll_grouplock grouplock;
int rc;
mutex_lock(&lli->lli_group_mutex);
}
- if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
+ if (lfd->fd_flags & LL_FILE_GROUP_LOCKED) {
rc = -EINVAL;
CWARN("%s: group lock already existed with gid %lu: rc = %d\n",
- ll_i2sbi(inode)->ll_fsname, fd->fd_grouplock.lg_gid, rc);
+ ll_i2sbi(inode)->ll_fsname, lfd->fd_grouplock.lg_gid, rc);
GOTO(out, rc);
}
if (arg != lli->lli_group_gid && lli->lli_group_users != 0) {
wait_var_event(&lli->lli_group_users, !lli->lli_group_users);
GOTO(retry, rc = 0);
}
- LASSERT(fd->fd_grouplock.lg_lock == NULL);
+ LASSERT(lfd->fd_grouplock.lg_lock == NULL);
/*
* XXX: group lock needs to protect all OST objects while PFL
if (rc)
GOTO(out, rc);
- fd->fd_flags |= LL_FILE_GROUP_LOCKED;
- fd->fd_grouplock = grouplock;
+ lfd->fd_flags |= LL_FILE_GROUP_LOCKED;
+ lfd->fd_grouplock = grouplock;
if (lli->lli_group_users == 0)
lli->lli_group_gid = grouplock.lg_gid;
lli->lli_group_users++;
unsigned long arg)
{
struct ll_inode_info *lli = ll_i2info(inode);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct ll_grouplock grouplock;
int rc;
ENTRY;
mutex_lock(&lli->lli_group_mutex);
- if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED)) {
+ if (!(lfd->fd_flags & LL_FILE_GROUP_LOCKED)) {
rc = -EINVAL;
CWARN("%s: no group lock held: rc = %d\n",
ll_i2sbi(inode)->ll_fsname, rc);
GOTO(out, rc);
}
- LASSERT(fd->fd_grouplock.lg_lock != NULL);
+ LASSERT(lfd->fd_grouplock.lg_lock != NULL);
- if (fd->fd_grouplock.lg_gid != arg) {
+ if (lfd->fd_grouplock.lg_gid != arg) {
rc = -EINVAL;
CWARN("%s: group lock %lu not match current id %lu: rc = %d\n",
- ll_i2sbi(inode)->ll_fsname, arg, fd->fd_grouplock.lg_gid,
+ ll_i2sbi(inode)->ll_fsname, arg, lfd->fd_grouplock.lg_gid,
rc);
GOTO(out, rc);
}
- grouplock = fd->fd_grouplock;
- memset(&fd->fd_grouplock, 0, sizeof(fd->fd_grouplock));
- fd->fd_flags &= ~LL_FILE_GROUP_LOCKED;
+ grouplock = lfd->fd_grouplock;
+ memset(&lfd->fd_grouplock, 0, sizeof(lfd->fd_grouplock));
+ lfd->fd_flags &= ~LL_FILE_GROUP_LOCKED;
cl_put_grouplock(&grouplock);
static int ll_lock_noexpand(struct file *file, int flags)
{
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
- fd->ll_lock_no_expand = !(flags & LF_UNSET);
+ lfd->ll_lock_no_expand = !(flags & LF_UNSET);
return 0;
}
void __user *uarg)
{
struct inode *inode = file_inode(file);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct ll_inode_info *lli = ll_i2info(inode);
struct obd_client_handle *och = NULL;
struct split_param sp;
ENTRY;
mutex_lock(&lli->lli_och_mutex);
- if (fd->fd_lease_och != NULL) {
- och = fd->fd_lease_och;
- fd->fd_lease_och = NULL;
+ if (lfd->fd_lease_och != NULL) {
+ och = lfd->fd_lease_och;
+ lfd->fd_lease_och = NULL;
}
mutex_unlock(&lli->lli_och_mutex);
attached);
}
- ll_layout_refresh(inode, &fd->fd_layout_version);
+ ll_layout_refresh(inode, &lfd->fd_layout_version);
if (!rc)
rc = ll_lease_type_from_fmode(fmode);
{
struct inode *inode = file_inode(file);
struct ll_inode_info *lli = ll_i2info(inode);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct obd_client_handle *och = NULL;
__u64 open_flags = 0;
bool lease_broken;
ll_lease_close(och, inode, NULL);
RETURN(rc);
}
- rc = ll_layout_refresh(inode, &fd->fd_layout_version);
+ rc = ll_layout_refresh(inode, &lfd->fd_layout_version);
if (rc) {
ll_lease_close(och, inode, NULL);
RETURN(rc);
rc = 0;
mutex_lock(&lli->lli_och_mutex);
- if (fd->fd_lease_och == NULL) {
- fd->fd_lease_och = och;
+ if (lfd->fd_lease_och == NULL) {
+ lfd->fd_lease_och = och;
och = NULL;
}
mutex_unlock(&lli->lli_och_mutex);
ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct inode *inode = file_inode(file);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
struct ll_sb_info *sbi = ll_i2sbi(inode);
void __user *uarg = (void __user *)arg;
int flags, rc;
switch (cmd) {
case LL_IOC_GETFLAGS:
/* Get the current value of the file flags */
- return put_user(fd->fd_flags, (int __user *)arg);
+ return put_user(lfd->fd_flags, (int __user *)arg);
case LL_IOC_SETFLAGS:
case LL_IOC_CLRFLAGS:
/* Set or clear specific file flags */
RETURN(rc);
}
- fd->fd_flags |= flags;
+ lfd->fd_flags |= flags;
} else {
- fd->fd_flags &= ~flags;
+ lfd->fd_flags &= ~flags;
}
RETURN(0);
case LL_IOC_LOV_SETSTRIPE:
lli = ll_i2info(inode);
mutex_lock(&lli->lli_och_mutex);
- if (fd->fd_lease_och != NULL) {
- och = fd->fd_lease_och;
- fd->fd_lease_och = NULL;
+ if (lfd->fd_lease_och != NULL) {
+ och = lfd->fd_lease_och;
+ lfd->fd_lease_och = NULL;
}
mutex_unlock(&lli->lli_och_mutex);
if (och == NULL)
fmode_t fmode = 0;
mutex_lock(&lli->lli_och_mutex);
- if (fd->fd_lease_och != NULL) {
- struct obd_client_handle *och = fd->fd_lease_och;
+ if (lfd->fd_lease_och != NULL) {
+ struct obd_client_handle *och = lfd->fd_lease_och;
lock = ldlm_handle2lock(&och->och_lease_handle);
if (lock != NULL) {
if (!(file->f_flags & O_DIRECT))
RETURN(-EINVAL);
- fd->fd_designated_mirror = arg;
+ lfd->fd_designated_mirror = arg;
RETURN(0);
}
case LL_IOC_HEAT_GET: {
{
struct inode *inode = file_inode(file);
struct ll_inode_info *lli = ll_i2info(inode);
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
int rc, err;
LASSERT(!S_ISDIR(inode->i_mode));
/* The application has been told write failure already.
* Do not report failure again.
*/
- if (fd->fd_write_failed)
+ if (lfd->fd_write_failed)
return 0;
return rc ? -EIO : 0;
}
}
if (S_ISREG(inode->i_mode)) {
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
bool cached;
/* Sync metadata on MDT first, and then sync the cached data
if (rc == 0 && err < 0)
rc = err;
if (rc < 0)
- fd->fd_write_failed = true;
+ lfd->fd_write_failed = true;
else
- fd->fd_write_failed = false;
+ lfd->fd_write_failed = false;
}
if (!rc)
static int
ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock)
{
- struct ll_file_data *fd = file->private_data;
+ struct ll_file_data *lfd = file->private_data;
ENTRY;
/*
* for one file. And the entire message rate on the client is limited
* by CDEBUG_LIMIT too.
*/
- if (!(fd->fd_flags & LL_FILE_FLOCK_WARNING)) {
- fd->fd_flags |= LL_FILE_FLOCK_WARNING;
+ if (!(lfd->fd_flags & LL_FILE_FLOCK_WARNING)) {
+ lfd->fd_flags |= LL_FILE_FLOCK_WARNING;
CDEBUG_LIMIT(D_CONSOLE,
"flock disabled, mount with '-o [local]flock' to enable\r\n");
}