public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Benjamin LaHaise <bcrl@kvack.org>
Cc: Linus Torvalds <torvalds@osdl.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-aio@kvack.org
Subject: Re: [rfc] rework aio migrate pages to use aio fs
Date: Thu, 3 Oct 2013 03:22:51 +0100	[thread overview]
Message-ID: <20131003022251.GB13318@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20130917141825.GF11526@kvack.org>

On Tue, Sep 17, 2013 at 10:18:25AM -0400, Benjamin LaHaise wrote:
> +static int aio_set_page_dirty(struct page *page)
> +{
> +	return 0;
> +};
> +
> +static const struct address_space_operations aio_aops = {
> +	.set_page_dirty = aio_set_page_dirty,
> +};
> +
> +/*
> + * A single inode exists for each aio_inode file.  The inodes are only
> + * used for mapping the event ring buffers in order to make it possible
> + * to provide migration ops to the vm.
> + */
> +static struct inode *aio_inode_mkinode(struct super_block *s)
> +{
> +	struct inode *inode = new_inode_pseudo(s);
> +
> +	if (!inode)
> +		return ERR_PTR(-ENOMEM);
> +
> +	inode->i_ino = get_next_ino();
> +	inode->i_fop = &aio_ring_fops;
> +	inode->i_mapping->a_ops = &aio_aops;
> +
> +	/*
> +	 * Mark the inode dirty from the very beginning,
> +	 * that way it will never be moved to the dirty
> +	 * list because mark_inode_dirty() will think
> +	 * that it already _is_ on the dirty list.
> +	 */
> +	inode->i_state = I_DIRTY;
> +	inode->i_mode = S_IRUSR | S_IWUSR;
> +	inode->i_uid = current_fsuid();
> +	inode->i_gid = current_fsgid();
> +	inode->i_flags |= S_PRIVATE;
> +	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
> +	return inode;
> +}

FWIW, I would've taken that to fs/libfs.c, sans the assignment of ->i_fop.
BTW, are you sure that you want it to be opened via procfs symlink?  Is that
even possible?  IOW, what's that ->i_fop for?

> +struct file *aio_inode_getfile_private(const char *name,
> +				       const struct file_operations *fops,
> +				       void *priv, int flags)

Why is it not static?  And why bother with fops as argument, etc.?

> +	if (fops->owner && !try_module_get(fops->owner))
> +		return ERR_PTR(-ENOENT);

Also pointless, AFAICS.  BTW, you've just open-coded fops_get(fops), not
that it mattered in this case...

> +	inode = aio_inode_mkinode(aio_mnt->mnt_sb);
> +	if (IS_ERR(inode)) {
> +		file = ERR_PTR(-ENOMEM);
> +		goto err_module;
> +	}
> +
> +	/*
> +	 * Link the inode to a directory entry by creating a unique name
> +	 * using the inode sequence number.
> +	 */
> +	file = ERR_PTR(-ENOMEM);
> +	this.name = name;
> +	this.len = strlen(name);
> +	this.hash = 0;

Umm...  ITYM
	struct qstr this = QSTR_INIT("[aio]", 5);
, if not
	path.dentry = d_alloc_pseudo(aio_mnt->mnt_sb,
				     &(struct qstr)QSTR_INIT("[aio]", 5));
> +	if (!path.dentry)
> +		goto err_module;
> +
> +	path.mnt = mntget(aio_mnt);
> +
> +	d_instantiate(path.dentry, inode);
> +
> +	file = alloc_file(&path, OPEN_FMODE(flags), fops);
> +	if (IS_ERR(file))
> +		goto err_dput;

> +	file->f_mapping = inode->i_mapping;

Pointless, BTW - alloc_file() will have already set it that way.

> +	file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
> +	file->private_data = priv;
> +
> +	return file;
> +
> +err_dput:
> +	path_put(&path);
> +err_module:
> +	module_put(fops->owner);

And that module_put is pointless as well here.

  reply	other threads:[~2013-10-03  2:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-13 16:59 [GIT PULL] aio changes for 3.12 Benjamin LaHaise
2013-09-13 18:42 ` Al Viro
2013-09-17 14:18   ` [rfc] rework aio migrate pages to use aio fs Benjamin LaHaise
2013-10-03  2:22     ` Al Viro [this message]
2013-10-03  2:50       ` Al Viro
2013-10-09 13:55         ` Benjamin LaHaise

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131003022251.GB13318@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=bcrl@kvack.org \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox