All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-next@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Howells <dhowells@redhat.com>
Subject: Re: linux-next: manual merge of the vfs tree with the ext4 tree
Date: Tue, 14 Apr 2015 13:00:00 -0400	[thread overview]
Message-ID: <20150414170000.GB29810@thunk.org> (raw)
In-Reply-To: <20150414014855.GU889@ZenIV.linux.org.uk>

On Tue, Apr 14, 2015 at 02:48:55AM +0100, Al Viro wrote:
> On Tue, Apr 14, 2015 at 11:30:25AM +1000, Stephen Rothwell wrote:
> >  +static void ext4_put_link(struct dentry *dentry, struct nameidata *nd,
> >  +			  void *cookie)
> >  +{
> >  +	struct page *page = cookie;
> >  +	char *buf = nd_get_link(nd);
> >  +
> >  +	if (page) {
> >  +		kunmap(page);
> >  +		page_cache_release(page);
> >  +	}
> >  +	if (buf) {
> >  +		nd_set_link(nd, NULL);
> >  +		kfree(buf);
> 
> What the hell is that for?  ->put_link() has no damn reason to call
> nd_set_link(); the whole _point_ of ->put_link() is to free what needs
> to be freed when we discard a stack element.  And why, in the name of
> everything unholy, does it need to keep *any* page mapped?

The nd_set_link(nd, NULL) call was to clear out the link before it was
freed.  No one else seems to be doing it, so I'm happy to drop it.

> Look, either nd_get_link() points inside that page (in which case that
> kfree() is obviously invalid), or it points at kmalloc'ed buffer.  In
> which case kfree() is correct, but WTF do you need anything _else_?
> Such as mapped pages, etc.

Yes, it's either one or the other.

1) In the case of an unencrypted symlink which is too big to fit in
the inode, we map in the first (only) block of the symlink, and set
the link to it.

2) In the case of an encrypted symlink, we allocate memory and decrypt
from the first block (or the i_block[] array in the inode), and then
release the page if necessary.

I suppose we could have gone from two struct inode_operations (for
fast and "slow" symlinks), to four struct inodes_operations (for
[fast, unencrypted symlinks], [fast, encrypted symlinks], [slow,
unencrypted symlinks], and [slow, encrypted symlinks]), but it was
simpler to use a single follow_link() and put_link() function to
handle multiple cases.

Cheers,

					- Ted

  reply	other threads:[~2015-04-14 17:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14  1:30 linux-next: manual merge of the vfs tree with the ext4 tree Stephen Rothwell
2015-04-14  1:48 ` Al Viro
2015-04-14 17:00   ` Theodore Ts'o [this message]
2015-04-14 17:17     ` Al Viro
2015-04-14 21:02       ` Theodore Ts'o
2015-04-14 21:14         ` Al Viro
  -- strict thread matches above, loose matches on Subject: below --
2020-01-27 22:51 Stephen Rothwell
2016-05-17  0:23 Stephen Rothwell
2016-05-17  3:16 ` Theodore Ts'o
2016-05-18 14:25 ` Arnd Bergmann
2016-05-19  1:26   ` Stephen Rothwell
2015-06-09  2:47 Stephen Rothwell
2015-05-11  0:49 Stephen Rothwell
2015-04-15  1:35 Stephen Rothwell
2015-04-13  1:48 Stephen Rothwell
2015-04-13  1:43 Stephen Rothwell
2015-04-07  4:00 Stephen Rothwell
2015-04-07  7:02 ` Christoph Hellwig
2015-04-07  7:36   ` Stephen Rothwell
2015-04-08  3:26   ` Theodore Ts'o
2015-04-14 16:18     ` Christoph Hellwig
2015-04-14 20:43       ` Theodore Ts'o
2014-05-27  2:07 Stephen Rothwell
2014-04-22  1:13 Stephen Rothwell
2012-01-06  2:54 Stephen Rothwell
2012-01-06 20:46 ` Djalal Harouni
2011-12-21  0:18 Stephen Rothwell
2011-12-21  0:43 ` Stephen Rothwell
2011-07-18  3:36 Stephen Rothwell
2011-07-25  2:38 ` Stephen Rothwell
2009-05-19  4:23 Stephen Rothwell

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=20150414170000.GB29810@thunk.org \
    --to=tytso@mit.edu \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=viro@ZenIV.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.