Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48eddfd5 authored by Al Viro's avatar Al Viro
Browse files

lustre: switch ll_intent_file_open() to struct dentry *



... because fake struct file is wrong.

ll_prep_inode() in there is an atrocity - despite passing a pointer to
inode by address, it actually only uses the value when that value is
non-NULL, as it will be here.

Oh, and ->d_parent of anything is never NULL.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 946e51f2
Loading
Loading
Loading
Loading
+12 −15
Original line number Original line Diff line number Diff line
@@ -394,21 +394,19 @@ int ll_file_release(struct inode *inode, struct file *file)
	return rc;
	return rc;
}
}


static int ll_intent_file_open(struct file *file, void *lmm,
static int ll_intent_file_open(struct dentry *dentry, void *lmm,
			       int lmmsize, struct lookup_intent *itp)
			       int lmmsize, struct lookup_intent *itp)
{
{
	struct ll_sb_info *sbi = ll_i2sbi(file->f_dentry->d_inode);
	struct inode *inode = dentry->d_inode;
	struct dentry *parent = file->f_dentry->d_parent;
	struct ll_sb_info *sbi = ll_i2sbi(inode);
	const char *name = file->f_dentry->d_name.name;
	struct dentry *parent = dentry->d_parent;
	const int len = file->f_dentry->d_name.len;
	const char *name = dentry->d_name.name;
	const int len = dentry->d_name.len;
	struct md_op_data *op_data;
	struct md_op_data *op_data;
	struct ptlrpc_request *req;
	struct ptlrpc_request *req;
	__u32 opc = LUSTRE_OPC_ANY;
	__u32 opc = LUSTRE_OPC_ANY;
	int rc;
	int rc;


	if (!parent)
		return -ENOENT;

	/* Usually we come here only for NFSD, and we want open lock.
	/* Usually we come here only for NFSD, and we want open lock.
	   But we can also get here with pre 2.6.15 patchless kernels, and in
	   But we can also get here with pre 2.6.15 patchless kernels, and in
	   that case that lock is also ok */
	   that case that lock is also ok */
@@ -425,7 +423,7 @@ static int ll_intent_file_open(struct file *file, void *lmm,
	}
	}


	op_data  = ll_prep_md_op_data(NULL, parent->d_inode,
	op_data  = ll_prep_md_op_data(NULL, parent->d_inode,
				      file->f_dentry->d_inode, name, len,
				      inode, name, len,
				      O_RDWR, opc, NULL);
				      O_RDWR, opc, NULL);
	if (IS_ERR(op_data))
	if (IS_ERR(op_data))
		return PTR_ERR(op_data);
		return PTR_ERR(op_data);
@@ -441,7 +439,7 @@ static int ll_intent_file_open(struct file *file, void *lmm,
		if (!it_disposition(itp, DISP_OPEN_OPEN) ||
		if (!it_disposition(itp, DISP_OPEN_OPEN) ||
		     it_open_error(DISP_OPEN_OPEN, itp))
		     it_open_error(DISP_OPEN_OPEN, itp))
			goto out;
			goto out;
		ll_release_openhandle(file->f_dentry, itp);
		ll_release_openhandle(dentry, itp);
		goto out;
		goto out;
	}
	}


@@ -456,10 +454,9 @@ static int ll_intent_file_open(struct file *file, void *lmm,
		goto out;
		goto out;
	}
	}


	rc = ll_prep_inode(&file->f_dentry->d_inode, req, NULL, itp);
	rc = ll_prep_inode(&inode, req, NULL, itp);
	if (!rc && itp->d.lustre.it_lock_mode)
	if (!rc && itp->d.lustre.it_lock_mode)
		ll_set_lock_data(sbi->ll_md_exp, file->f_dentry->d_inode,
		ll_set_lock_data(sbi->ll_md_exp, inode, itp, NULL);
				 itp, NULL);


out:
out:
	ptlrpc_req_finished(req);
	ptlrpc_req_finished(req);
@@ -652,7 +649,7 @@ int ll_file_open(struct inode *inode, struct file *file)
			   result in a deadlock */
			   result in a deadlock */
			mutex_unlock(&lli->lli_och_mutex);
			mutex_unlock(&lli->lli_och_mutex);
			it->it_create_mode |= M_CHECK_STALE;
			it->it_create_mode |= M_CHECK_STALE;
			rc = ll_intent_file_open(file, NULL, 0, it);
			rc = ll_intent_file_open(file->f_path.dentry, NULL, 0, it);
			it->it_create_mode &= ~M_CHECK_STALE;
			it->it_create_mode &= ~M_CHECK_STALE;
			if (rc)
			if (rc)
				goto out_openerr;
				goto out_openerr;
@@ -1371,7 +1368,7 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
	}
	}


	ll_inode_size_lock(inode);
	ll_inode_size_lock(inode);
	rc = ll_intent_file_open(file, lum, lum_size, &oit);
	rc = ll_intent_file_open(file->f_path.dentry, lum, lum_size, &oit);
	if (rc)
	if (rc)
		goto out_unlock;
		goto out_unlock;
	rc = oit.d.lustre.it_status;
	rc = oit.d.lustre.it_status;