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

Commit e63fa0d4 authored by Al Viro's avatar Al Viro
Browse files

Merge branch 'for-lustre' into for-next

parents 08d4f772 f76c23da
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1025,8 +1025,8 @@ static int tracefiled(void *arg)

			if (f_pos >= (off_t)cfs_tracefile_size)
				f_pos = 0;
			else if (f_pos > i_size_read(filp->f_dentry->d_inode))
				f_pos = i_size_read(filp->f_dentry->d_inode);
			else if (f_pos > i_size_read(file_inode(filp)))
				f_pos = i_size_read(file_inode(filp));

			buf = kmap(tage->page);
			rc = vfs_write(filp, (__force const char __user *)buf,
+9 −10
Original line number Diff line number Diff line
@@ -151,10 +151,10 @@ static int ll_ddelete(const struct dentry *de)
{
	LASSERT(de);

	CDEBUG(D_DENTRY, "%s dentry %.*s (%p, parent %p, inode %p) %s%s\n",
	CDEBUG(D_DENTRY, "%s dentry %pd (%p, parent %p, inode %p) %s%s\n",
	       d_lustre_invalid((struct dentry *)de) ? "deleting" : "keeping",
	       de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
	       d_unhashed((struct dentry *)de) ? "" : "hashed,",
	       de, de, de->d_parent, de->d_inode,
	       d_unhashed(de) ? "" : "hashed,",
	       list_empty(&de->d_subdirs) ? "" : "subdirs");

	/* kernel >= 2.6.38 last refcount is decreased after this function. */
@@ -180,8 +180,8 @@ int ll_d_init(struct dentry *de)
{
	LASSERT(de != NULL);

	CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n",
		de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
	CDEBUG(D_DENTRY, "ldd on dentry %pd (%p) parent %p inode %p refc %d\n",
		de, de, de->d_parent, de->d_inode,
		d_count(de));

	if (de->d_fsdata == NULL) {
@@ -259,9 +259,8 @@ void ll_invalidate_aliases(struct inode *inode)

	ll_lock_dcache(inode);
	ll_d_hlist_for_each_entry(dentry, p, &inode->i_dentry, d_u.d_alias) {
		CDEBUG(D_DENTRY, "dentry in drop %.*s (%p) parent %p "
		       "inode %p flags %d\n", dentry->d_name.len,
		       dentry->d_name.name, dentry, dentry->d_parent,
		CDEBUG(D_DENTRY, "dentry in drop %pd (%p) parent %p "
		       "inode %p flags %d\n", dentry, dentry, dentry->d_parent,
		       dentry->d_inode, dentry->d_flags);

		if (unlikely(dentry == dentry->d_sb->s_root)) {
@@ -352,8 +351,8 @@ static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags)
{
	int rc;

	CDEBUG(D_VFSTRACE, "VFS Op:name=%s, flags=%u\n",
	       dentry->d_name.name, flags);
	CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, flags=%u\n",
	       dentry, flags);

	rc = ll_revalidate_dentry(dentry, flags);
	return rc;
+4 −5
Original line number Diff line number Diff line
@@ -593,7 +593,7 @@ int ll_dir_read(struct inode *inode, struct dir_context *ctx)

static int ll_readdir(struct file *filp, struct dir_context *ctx)
{
	struct inode		*inode	= filp->f_dentry->d_inode;
	struct inode		*inode	= file_inode(filp);
	struct ll_file_data	*lfd	= LUSTRE_FPRIVATE(filp);
	struct ll_sb_info	*sbi	= ll_i2sbi(inode);
	int			hash64	= sbi->ll_flags & LL_SBI_64BIT_HASH;
@@ -1242,7 +1242,7 @@ ll_getname(const char __user *filename)

static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	struct inode *inode = file->f_dentry->d_inode;
	struct inode *inode = file_inode(file);
	struct ll_sb_info *sbi = ll_i2sbi(inode);
	struct obd_ioctl_data *data;
	int rc = 0;
@@ -1389,7 +1389,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
				return -EFAULT;
		}

		if (inode->i_sb->s_root == file->f_dentry)
		if (is_root_inode(inode))
			set_default = 1;

		/* in v1 and v3 cases lumv1 points to data */
@@ -1780,8 +1780,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
		return ll_flush_ctx(inode);
#ifdef CONFIG_FS_POSIX_ACL
	case LL_IOC_RMTACL: {
	    if (sbi->ll_flags & LL_SBI_RMT_CLIENT &&
		inode == inode->i_sb->s_root->d_inode) {
	    if (sbi->ll_flags & LL_SBI_RMT_CLIENT && is_root_inode(inode)) {
		struct ll_file_data *fd = LUSTRE_FPRIVATE(file);

		LASSERT(fd != NULL);
+67 −79
Original line number Diff line number Diff line
@@ -266,6 +266,10 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
{
	struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
	struct ll_inode_info *lli = ll_i2info(inode);
	int lockmode;
	__u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
	struct lustre_handle lockh;
	ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}};
	int rc = 0;

	/* clear group lock, if present */
@@ -292,12 +296,6 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,

	/* 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) {
@@ -316,15 +314,8 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
	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);
		}
	} else {
		CERROR("Releasing a file %p with negative dentry %p. Name %s",
		       file, file->f_dentry, file->f_dentry->d_name.name);
	}
			   LDLM_IBITS, &policy, lockmode, &lockh))
		rc = ll_md_real_close(inode, fd->fd_omode);

out:
	LUSTRE_FPRIVATE(file) = NULL;
@@ -350,8 +341,7 @@ int ll_file_release(struct inode *inode, struct file *file)
	       inode->i_generation, inode);

#ifdef CONFIG_FS_POSIX_ACL
	if (sbi->ll_flags & LL_SBI_RMT_CLIENT &&
	    inode == inode->i_sb->s_root->d_inode) {
	if (sbi->ll_flags & LL_SBI_RMT_CLIENT && is_root_inode(inode)) {
		struct ll_file_data *fd = LUSTRE_FPRIVATE(file);

		LASSERT(fd != NULL);
@@ -363,7 +353,7 @@ int ll_file_release(struct inode *inode, struct file *file)
	}
#endif

	if (inode->i_sb->s_root != file->f_dentry)
	if (!is_root_inode(inode))
		ll_stats_ops_tally(sbi, LPROC_LL_RELEASE, 1);
	fd = LUSTRE_FPRIVATE(file);
	LASSERT(fd != NULL);
@@ -375,7 +365,7 @@ int ll_file_release(struct inode *inode, struct file *file)
	    lli->lli_opendir_pid != 0)
		ll_stop_statahead(inode, lli->lli_opendir_key);

	if (inode->i_sb->s_root == file->f_dentry) {
	if (is_root_inode(inode)) {
		LUSTRE_FPRIVATE(file) = NULL;
		ll_file_data_put(fd);
		return 0;
@@ -394,21 +384,19 @@ int ll_file_release(struct inode *inode, struct file *file)
	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)
{
	struct ll_sb_info *sbi = ll_i2sbi(file->f_dentry->d_inode);
	struct dentry *parent = file->f_dentry->d_parent;
	const char *name = file->f_dentry->d_name.name;
	const int len = file->f_dentry->d_name.len;
	struct inode *inode = dentry->d_inode;
	struct ll_sb_info *sbi = ll_i2sbi(inode);
	struct dentry *parent = dentry->d_parent;
	const char *name = dentry->d_name.name;
	const int len = dentry->d_name.len;
	struct md_op_data *op_data;
	struct ptlrpc_request *req;
	__u32 opc = LUSTRE_OPC_ANY;
	int rc;

	if (!parent)
		return -ENOENT;

	/* 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
	   that case that lock is also ok */
@@ -425,7 +413,7 @@ static int ll_intent_file_open(struct file *file, void *lmm,
	}

	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);
	if (IS_ERR(op_data))
		return PTR_ERR(op_data);
@@ -441,7 +429,7 @@ static int ll_intent_file_open(struct file *file, void *lmm,
		if (!it_disposition(itp, DISP_OPEN_OPEN) ||
		     it_open_error(DISP_OPEN_OPEN, itp))
			goto out;
		ll_release_openhandle(file->f_dentry, itp);
		ll_release_openhandle(inode, itp);
		goto out;
	}

@@ -456,10 +444,9 @@ static int ll_intent_file_open(struct file *file, void *lmm,
		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)
		ll_set_lock_data(sbi->ll_md_exp, file->f_dentry->d_inode,
				 itp, NULL);
		ll_set_lock_data(sbi->ll_md_exp, inode, itp, NULL);

out:
	ptlrpc_req_finished(req);
@@ -501,7 +488,7 @@ static int ll_och_fill(struct obd_export *md_exp, struct lookup_intent *it,
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_inode(file);
	struct ll_inode_info *lli = ll_i2info(inode);

	LASSERT(!LUSTRE_FPRIVATE(file));
@@ -574,7 +561,7 @@ int ll_file_open(struct inode *inode, struct file *file)
		spin_unlock(&lli->lli_sa_lock);
	}

	if (inode->i_sb->s_root == file->f_dentry) {
	if (is_root_inode(inode)) {
		LUSTRE_FPRIVATE(file) = fd;
		return 0;
	}
@@ -632,7 +619,7 @@ int ll_file_open(struct inode *inode, struct file *file)
				goto out_openerr;
			}

			ll_release_openhandle(file->f_dentry, it);
			ll_release_openhandle(inode, it);
		}
		(*och_usecount)++;

@@ -652,7 +639,7 @@ int ll_file_open(struct inode *inode, struct file *file)
			   result in a deadlock */
			mutex_unlock(&lli->lli_och_mutex);
			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;
			if (rc)
				goto out_openerr;
@@ -1065,7 +1052,7 @@ int ll_glimpse_ioctl(struct ll_sb_info *sbi, struct lov_stripe_md *lsm,
static bool file_is_noatime(const struct file *file)
{
	const struct vfsmount *mnt = file->f_path.mnt;
	const struct inode *inode = file->f_path.dentry->d_inode;
	const struct inode *inode = file_inode(file);

	/* Adapted from file_accessed() and touch_atime().*/
	if (file->f_flags & O_NOATIME)
@@ -1091,7 +1078,7 @@ static bool file_is_noatime(const struct file *file)

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_inode(file);

	io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK;
	if (write) {
@@ -1117,7 +1104,7 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
		   struct file *file, enum cl_io_type iot,
		   loff_t *ppos, size_t count)
{
	struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode);
	struct ll_inode_info *lli = ll_i2info(file_inode(file));
	struct ll_file_data  *fd  = LUSTRE_FPRIVATE(file);
	struct cl_io	 *io;
	ssize_t	       result;
@@ -1178,20 +1165,20 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
	/* If any bit been read/written (result != 0), we just return
	 * short read/write instead of restart io. */
	if ((result == 0 || result == -ENODATA) && io->ci_need_restart) {
		CDEBUG(D_VFSTRACE, "Restart %s on %s from %lld, count:%zd\n",
		CDEBUG(D_VFSTRACE, "Restart %s on %pD from %lld, count:%zd\n",
		       iot == CIT_READ ? "read" : "write",
		       file->f_dentry->d_name.name, *ppos, count);
		       file, *ppos, count);
		LASSERTF(io->ci_nob == 0, "%zd", io->ci_nob);
		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(file_inode(file)),
					   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(file_inode(file)),
					   LPROC_LL_WRITE_BYTES, result);
			fd->fd_write_failed = false;
		} else if (result != -ERESTARTSYS) {
@@ -1354,7 +1341,7 @@ static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg)
	return ll_lov_recreate(inode, &oi, ost_idx);
}

int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry,
			     int flags, struct lov_user_md *lum, int lum_size)
{
	struct lov_stripe_md *lsm = NULL;
@@ -1371,21 +1358,20 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
	}

	ll_inode_size_lock(inode);
	rc = ll_intent_file_open(file, lum, lum_size, &oit);
	rc = ll_intent_file_open(dentry, lum, lum_size, &oit);
	if (rc)
		goto out_unlock;
	rc = oit.d.lustre.it_status;
	if (rc < 0)
		goto out_req_free;

	ll_release_openhandle(file->f_dentry, &oit);
	ll_release_openhandle(inode, &oit);

out_unlock:
	ll_inode_size_unlock(inode);
	ll_intent_release(&oit);
	ccc_inode_lsm_put(inode, lsm);
out:
	cl_lov_delay_create_clear(&file->f_flags);
	return rc;
out_req_free:
	ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data);
@@ -1499,7 +1485,9 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
		return -EFAULT;
	}

	rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size);
	rc = ll_lov_setstripe_ea_info(inode, file->f_path.dentry, flags, lump,
				     lum_size);
	cl_lov_delay_create_clear(&file->f_flags);

	OBD_FREE_LARGE(lump, lum_size);
	return rc;
@@ -1526,7 +1514,9 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file,
			return -EFAULT;
	}

	rc = ll_lov_setstripe_ea_info(inode, file, flags, lumv1, lum_size);
	rc = ll_lov_setstripe_ea_info(inode, file->f_path.dentry, flags, lumv1,
				      lum_size);
	cl_lov_delay_create_clear(&file->f_flags);
	if (rc == 0) {
		struct lov_stripe_md *lsm;
		__u32 gen;
@@ -1631,22 +1621,21 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg)
/**
 * Close inode open handle
 *
 * \param dentry [in]     dentry which contains the inode
 * \param inode  [in]     inode in question
 * \param it     [in,out] intent which contains open info and result
 *
 * \retval 0     success
 * \retval <0    failure
 */
int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it)
int ll_release_openhandle(struct inode *inode, struct lookup_intent *it)
{
	struct inode *inode = dentry->d_inode;
	struct obd_client_handle *och;
	int rc;

	LASSERT(inode);

	/* Root ? Do nothing. */
	if (dentry->d_inode->i_sb->s_root == dentry)
	if (is_root_inode(inode))
		return 0;

	/* No open handle to close? Move away */
@@ -1959,8 +1948,8 @@ static int ll_swap_layouts(struct file *file1, struct file *file2,
	if (!llss)
		return -ENOMEM;

	llss->inode1 = file1->f_dentry->d_inode;
	llss->inode2 = file2->f_dentry->d_inode;
	llss->inode1 = file_inode(file1);
	llss->inode2 = file_inode(file2);

	if (!S_ISREG(llss->inode2->i_mode)) {
		rc = -EINVAL;
@@ -2204,7 +2193,7 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
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_inode(file);
	struct ll_file_data	*fd = LUSTRE_FPRIVATE(file);
	int			 flags, rc;

@@ -2523,7 +2512,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

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_inode(file);
	loff_t retval, eof = 0;

	retval = offset + ((origin == SEEK_END) ? i_size_read(inode) :
@@ -2547,7 +2536,7 @@ static loff_t ll_file_seek(struct file *file, loff_t offset, int origin)

static int ll_flush(struct file *file, fl_owner_t id)
{
	struct inode *inode = file->f_dentry->d_inode;
	struct inode *inode = file_inode(file);
	struct ll_inode_info *lli = ll_i2info(inode);
	struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
	int rc, err;
@@ -2624,8 +2613,7 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,

int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
	struct dentry *dentry = file->f_dentry;
	struct inode *inode = dentry->d_inode;
	struct inode *inode = file_inode(file);
	struct ll_inode_info *lli = ll_i2info(inode);
	struct ptlrpc_request *req;
	struct obd_capa *oc;
@@ -2678,7 +2666,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
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_inode(file);
	struct ll_sb_info *sbi = ll_i2sbi(inode);
	struct ldlm_enqueue_info einfo = {
		.ei_type	= LDLM_FLOCK,
@@ -2902,8 +2890,8 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)

	LASSERT(inode != NULL);

	CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),name=%s\n",
	       inode->i_ino, inode->i_generation, inode, dentry->d_name.name);
	CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),name=%pd\n",
	       inode->i_ino, inode->i_generation, inode, dentry);

	exp = ll_i2mdexp(inode);

@@ -3113,7 +3101,7 @@ int ll_inode_permission(struct inode *inode, int mask)
       /* as root inode are NOT getting validated in lookup operation,
	* need to do it before permission check. */

	if (inode == inode->i_sb->s_root->d_inode) {
	if (is_root_inode(inode)) {
		rc = __ll_inode_revalidate(inode->i_sb->s_root,
					   MDS_INODELOCK_LOOKUP);
		if (rc)
+5 −5
Original line number Diff line number Diff line
@@ -748,7 +748,7 @@ int ll_file_release(struct inode *inode, struct file *file);
int ll_glimpse_ioctl(struct ll_sb_info *sbi,
		     struct lov_stripe_md *lsm, lstat_t *st);
void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch);
int ll_release_openhandle(struct dentry *, struct lookup_intent *);
int ll_release_openhandle(struct inode *, struct lookup_intent *);
int ll_md_real_close(struct inode *inode, fmode_t fmode);
void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
		      struct obd_client_handle **och, unsigned long flags);
@@ -763,7 +763,7 @@ struct posix_acl *ll_get_acl(struct inode *inode, int type);

int ll_inode_permission(struct inode *inode, int mask);

int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry,
			     int flags, struct lov_user_md *lum,
			     int lum_size);
int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
@@ -1413,7 +1413,7 @@ extern ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io,
static inline int ll_file_nolock(const struct file *file)
{
	struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
	struct inode *inode = file->f_dentry->d_inode;
	struct inode *inode = file_inode(file);

	LASSERT(fd != NULL);
	return ((fd->fd_flags & LL_FILE_IGNORE_LOCK) ||
@@ -1489,8 +1489,8 @@ static inline void __d_lustre_invalidate(struct dentry *dentry)
 */
static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
{
	CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p "
	       "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry,
	CDEBUG(D_DENTRY, "invalidate dentry %pd (%p) parent %p inode %p "
	       "refc %d\n", dentry, dentry,
	       dentry->d_parent, dentry->d_inode, d_count(dentry));

	spin_lock_nested(&dentry->d_lock,
Loading