static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
struct file *file)
{
- struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
- struct ll_inode_info *lli = ll_i2info(inode);
- int rc = 0;
- ENTRY;
+ ldlm_policy_data_t policy = {
+ .l_inodebits = { MDS_INODELOCK_OPEN },
+ };
+ __u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
+ struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+ struct ll_inode_info *lli = ll_i2info(inode);
+ struct lustre_handle lockh;
+ int lockmode;
+ int rc = 0;
+ ENTRY;
/* clear group lock, if present */
if (unlikely(fd->fd_flags & LL_FILE_GROUP_LOCKED))
/* Let's see if we have good enough OPEN lock on the file and if
we can skip talking to MDS */
- if (file->f_dentry->d_inode) { /* Can this ever be false? */
- int lockmode;
- __u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
- struct lustre_handle lockh;
- struct inode *inode = file->f_dentry->d_inode;
- ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}};
-
- mutex_lock(&lli->lli_och_mutex);
- if (fd->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) {
- lockmode = LCK_PR;
- LASSERT(lli->lli_open_fd_exec_count);
- lli->lli_open_fd_exec_count--;
- } else {
- lockmode = LCK_CR;
- LASSERT(lli->lli_open_fd_read_count);
- lli->lli_open_fd_read_count--;
- }
- mutex_unlock(&lli->lli_och_mutex);
-
- if (!md_lock_match(md_exp, flags, ll_inode2fid(inode),
- LDLM_IBITS, &policy, lockmode,
- &lockh)) {
- rc = ll_md_real_close(file->f_dentry->d_inode,
- fd->fd_omode);
- }
+ mutex_lock(&lli->lli_och_mutex);
+ if (fd->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) {
+ lockmode = LCK_PR;
+ LASSERT(lli->lli_open_fd_exec_count);
+ lli->lli_open_fd_exec_count--;
} else {
- CERROR("released file has negative dentry: file = %p, "
- "dentry = %p, name = %s\n",
- file, file->f_dentry, file->f_dentry->d_name.name);
+ lockmode = LCK_CR;
+ LASSERT(lli->lli_open_fd_read_count);
+ lli->lli_open_fd_read_count--;
}
+ mutex_unlock(&lli->lli_och_mutex);
+
+ if (!md_lock_match(md_exp, flags, ll_inode2fid(inode),
+ LDLM_IBITS, &policy, lockmode, &lockh))
+ rc = ll_md_real_close(inode, fd->fd_omode);
out:
LUSTRE_FPRIVATE(file) = NULL;
}
#endif
- if (inode->i_sb->s_root != file->f_dentry)
+ if (inode->i_sb->s_root != file->f_path.dentry)
ll_stats_ops_tally(sbi, LPROC_LL_RELEASE, 1);
fd = LUSTRE_FPRIVATE(file);
LASSERT(fd != NULL);
if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd)
ll_deauthorize_statahead(inode, fd);
- if (inode->i_sb->s_root == file->f_dentry) {
+ if (inode->i_sb->s_root == file->f_path.dentry) {
LUSTRE_FPRIVATE(file) = NULL;
ll_file_data_put(fd);
RETURN(0);
static int ll_intent_file_open(struct file *file, void *lmm, int lmmsize,
struct lookup_intent *itp)
{
- struct dentry *de = file->f_dentry;
+ struct dentry *de = file->f_path.dentry;
struct ll_sb_info *sbi = ll_i2sbi(de->d_inode);
struct dentry *parent = de->d_parent;
const char *name = NULL;
static int ll_local_open(struct file *file, struct lookup_intent *it,
struct ll_file_data *fd, struct obd_client_handle *och)
{
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode = file->f_path.dentry->d_inode;
ENTRY;
LASSERT(!LUSTRE_FPRIVATE(file));
if (S_ISDIR(inode->i_mode))
ll_authorize_statahead(inode, fd);
- if (inode->i_sb->s_root == file->f_dentry) {
+ if (inode->i_sb->s_root == file->f_path.dentry) {
LUSTRE_FPRIVATE(file) = fd;
RETURN(0);
}
GOTO(out_openerr, rc);
}
- ll_release_openhandle(file->f_dentry, it);
+ ll_release_openhandle(file->f_path.dentry, it);
}
(*och_usecount)++;
static void ll_io_init(struct cl_io *io, const struct file *file, int write)
{
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode = file->f_path.dentry->d_inode;
io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK;
if (write) {
loff_t *ppos, size_t count)
{
struct vvp_io *vio = vvp_env_io(env);
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode = file->f_path.dentry->d_inode;
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
struct cl_io *io;
ENTRY;
CDEBUG(D_VFSTRACE, "file: %s, type: %d ppos: "LPU64", count: %zu\n",
- file->f_dentry->d_name.name, iot, *ppos, count);
+ file->f_path.dentry->d_name.name, iot, *ppos, count);
restart:
io = vvp_env_thread_io(env);
if ((rc == 0 || rc == -ENODATA) && count > 0 && io->ci_need_restart) {
CDEBUG(D_VFSTRACE,
"%s: restart %s from %lld, count:%zu, result: %zd\n",
- file->f_dentry->d_name.name,
+ file->f_path.dentry->d_name.name,
iot == CIT_READ ? "read" : "write",
*ppos, count, result);
goto restart;
if (iot == CIT_READ) {
if (result > 0)
- ll_stats_ops_tally(ll_i2sbi(file->f_dentry->d_inode),
+ ll_stats_ops_tally(ll_i2sbi(inode),
LPROC_LL_READ_BYTES, result);
} else if (iot == CIT_WRITE) {
if (result > 0) {
- ll_stats_ops_tally(ll_i2sbi(file->f_dentry->d_inode),
+ ll_stats_ops_tally(ll_i2sbi(inode),
LPROC_LL_WRITE_BYTES, result);
fd->fd_write_failed = false;
} else if (rc != -ERESTARTSYS) {
if (rc < 0)
GOTO(out_unlock, rc);
- ll_release_openhandle(file->f_dentry, &oit);
+ ll_release_openhandle(file->f_path.dentry, &oit);
out_unlock:
ll_inode_size_unlock(inode);
if (llss == NULL)
RETURN(-ENOMEM);
- llss->inode1 = file1->f_dentry->d_inode;
- llss->inode2 = file2->f_dentry->d_inode;
+ llss->inode1 = file1->f_path.dentry->d_inode;
+ llss->inode2 = file2->f_path.dentry->d_inode;
rc = ll_check_swap_layouts_validity(llss->inode1, llss->inode2);
if (rc < 0)
mutex_lock(&inode->i_mutex);
- rc = ll_setattr_raw(file->f_dentry, attr, true);
+ rc = ll_setattr_raw(file->f_path.dentry, attr, true);
if (rc == -ENODATA)
rc = 0;
static long
ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode = file->f_path.dentry->d_inode;
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
int flags, rc;
ENTRY;
mutex_unlock(&lli->lli_och_mutex);
if (och == NULL)
GOTO(out, rc = -ENOLCK);
- inode2 = file2->f_dentry->d_inode;
+ inode2 = file2->f_path.dentry->d_inode;
rc = ll_swap_layouts_close(och, inode, inode2);
} else {
rc = ll_swap_layouts(file, file2, &lsl);
generic_file_llseek_size(struct file *file, loff_t offset, int origin,
loff_t maxsize, loff_t eof)
{
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode = file->f_path.dentry->d_inode;
switch (origin) {
case SEEK_END:
static loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
{
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode = file->f_path.dentry->d_inode;
loff_t retval, eof = 0;
ENTRY;
static int ll_flush(struct file *file, fl_owner_t id)
{
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode = file->f_path.dentry->d_inode;
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
int rc, err;
}
/*
- * When dentry is provided (the 'else' case), *file->f_dentry may be
+ * When dentry is provided (the 'else' case), *file->f_path.dentry may be
* null and dentry must be used directly rather than pulled from
- * *file->f_dentry as is done otherwise.
+ * *file->f_path.dentry as is done otherwise.
*/
#ifdef HAVE_FILE_FSYNC_4ARGS
int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
- struct dentry *dentry = file->f_dentry;
+ struct dentry *dentry = file->f_path.dentry;
#elif defined(HAVE_FILE_FSYNC_2ARGS)
int ll_fsync(struct file *file, int datasync)
{
- struct dentry *dentry = file->f_dentry;
+ struct dentry *dentry = file->f_path.dentry;
loff_t start = 0;
loff_t end = LLONG_MAX;
#else
static int
ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
{
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode = file->f_path.dentry->d_inode;
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ldlm_enqueue_info einfo = {
.ei_type = LDLM_FLOCK,
qstr.hash = full_name_hash(name, namelen);
qstr.name = name;
qstr.len = namelen;
- dchild = d_lookup(file->f_dentry, &qstr);
+ dchild = d_lookup(file->f_path.dentry, &qstr);
if (dchild != NULL) {
if (dchild->d_inode != NULL) {
child_inode = igrab(dchild->d_inode);