All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: NeilBrown <neilb@suse.de>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC][PATCHSET] non-recursive link_path_walk() and reducing stack footprint
Date: Tue, 21 Apr 2015 15:49:59 +0100	[thread overview]
Message-ID: <20150421144959.GR889@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20150420181222.GK889@ZenIV.linux.org.uk>

On Mon, Apr 20, 2015 at 07:12:22PM +0100, Al Viro wrote:

> 	Patches 2/24..6/24 are from Neil's RCU follow_link patchset; the
> rest of his patchset is, of course, derailed by the massage done here,
> but AFAICS we should be able to port it on top of this one with reasonably
> little PITA.

BTW, looking at the ->put_link() instances in the tree, after this series
all but one of them ignore *everything* other than cookie.  The only exception
is hppfs; it wants dentry (and its inode as well):

static void hppfs_put_link(struct dentry *dentry, void *cookie)
{
        struct dentry *proc_dentry = HPPFS_I(d_inode(dentry))->proc_dentry;

        if (d_inode(proc_dentry)->i_op->put_link)
                d_inode(proc_dentry)->i_op->put_link(proc_dentry, cookie);
}

Does anybody have objections against passing them inodes instead of dentries?
It would be a lot more convenient for RCU purposes...

Other observations about the Neil's series:
	* the games played in page_follow_link_light/page_put_link are
completely pointless; this
 void page_put_link(struct dentry *dentry, char *link, void *cookie)
 {
-       struct page *page = cookie;
+       struct page *page = (void *)((unsigned long)cookie & ~1UL);

        if (page) {
-               kunmap(page);
+               if (page == cookie)
+                       kunmap(page);
                page_cache_release(page);
        }
 }
is trivially avoided by making sure that inodes with such ->put_link() in
their inode_operations have
	mapping_set_gfp_mask(mapping,
			     mapping_get_gfp_mask(mapping) & ~__GFP_HIGHMEM);
done to them.  And to hell with that kmap/kunmap pair - it's a bad idea to
have kmap held across practically unlimited period, anyway (run into a hung
NFS server while traversing the symlink body, get stuck for minutes until it
times out).  I'll take care of that, it's not much work.
	* XFS: is there any reason why you guys don't separate inline and
non-inline symlinks?  Or don't just use page_follow_link_light() for the
latter...  Note, BTW, that NUL-termination for the latter will be taken
care of by page_getlink().  It's inline ones that look like crap, actually -
unless I'm misreading that code, the longest possible inline symlink will
have ip->i_df.if_u1.if_data completely filled, with no place for terminating
NUL.  Is that correct?  If so, it might make sense to have three variants -
short (== inline shorter than XFS_IFORK_DSIZE) just having ->follow_link()
return ip->i_df.if_u1.if_data and have xfs_setup_inode() do nd_terminate_link()
to make sure they are NUL-terminated, long (non-inline) just using
page_follow_link_light() and bogus (inline with length exactly equal to
XFS_IFORK_DSIZE); the last would be the only ones with XFS-specific non-trivial
->follow_link() - those really need to allocate a buffer and copy into it...

	FWIW, there's a potentially interesting alternative - the thing is,
normal callers of link_path_walk() already know the length of name; both
getname() and getname_kernel() calculate the lengths.  And ->follow_link()
tend to have the lengths available as well (and usually equal to ->i_size of
the inode in question).  So we might consider passing (pointer,length) pairs
to link_path_walk().  In principle, it might simplify things...  Comments?

	* logfs has ->follow_link equal to page_follow_link_light and
NULL ->put_link.  Obvious leak, and that one's -stable fodder - it had
been there all way back to original merge.  I'll send a fix in a minute.


  parent reply	other threads:[~2015-04-21 14:50 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20 18:12 [RFC][PATCHSET] non-recursive link_path_walk() and reducing stack footprint Al Viro
2015-04-20 18:12 ` [PATCH 01/24] lustre: rip the private symlink nesting limit out Al Viro
2015-04-20 19:08   ` Andreas Dilger
2015-04-20 19:22     ` Al Viro
2015-04-20 20:35       ` Al Viro
2015-04-20 18:12 ` [PATCH 02/24] VFS: replace {, total_}link_count in task_struct with pointer to nameidata Al Viro
2015-04-20 18:12 ` [PATCH 03/24] ovl: rearrange ovl_follow_link to it doesn't need to call ->put_link Al Viro
2015-04-20 18:12 ` [PATCH 04/24] VFS: replace nameidata arg to ->put_link with a char* Al Viro
2015-04-20 18:12 ` [PATCH 05/24] SECURITY: remove nameidata arg from inode_follow_link Al Viro
2015-04-20 18:12 ` [PATCH 06/24] VFS: remove nameidata args from ->follow_link Al Viro
2015-04-20 18:12 ` [PATCH 07/24] namei: expand nested_symlink() in its only caller Al Viro
2015-04-20 18:12 ` [PATCH 08/24] namei.c: separate the parts of follow_link() that find the link body Al Viro
2015-04-20 18:12 ` [PATCH 09/24] namei: fold follow_link() into link_path_walk() Al Viro
2015-04-20 18:12 ` [PATCH 10/24] link_path_walk: handle get_link() returning ERR_PTR() immediately Al Viro
2015-04-20 18:12 ` [PATCH 11/24] link_path_walk: don't bother with walk_component() after jumping link Al Viro
2015-04-20 18:12 ` [PATCH 12/24] link_path_walk: turn inner loop into explicit goto Al Viro
2015-04-20 18:12 ` [PATCH 13/24] link_path_walk: massage a bit more Al Viro
2015-04-20 18:12 ` [PATCH 14/24] link_path_walk: get rid of duplication Al Viro
2015-04-20 18:12 ` [PATCH 15/24] link_path_walk: final preparations to killing recursion Al Viro
2015-04-20 18:13 ` [PATCH 16/24] link_path_walk: kill the recursion Al Viro
2015-04-20 21:04   ` Linus Torvalds
2015-04-20 21:32     ` Al Viro
2015-04-20 21:39       ` Linus Torvalds
2015-04-20 21:51         ` Al Viro
2015-04-20 21:41       ` Linus Torvalds
2015-04-20 21:42         ` Linus Torvalds
2015-04-20 21:59           ` Al Viro
2015-04-20 21:52         ` Al Viro
2015-04-20 18:13 ` [PATCH 17/24] link_path_walk: split "return from recursive call" path Al Viro
2015-04-20 18:13 ` [PATCH 18/24] link_path_walk: cleanup - turn goto start; into continue; Al Viro
2015-04-20 18:13 ` [PATCH 19/24] namei: fold may_follow_link() into follow_link() Al Viro
2015-04-20 18:13 ` [PATCH 20/24] namei: introduce nameidata->stack Al Viro
2015-04-20 18:13 ` [PATCH 21/24] namei: regularize use of put_link() and follow_link(), trim arguments Al Viro
2015-04-20 18:13 ` [PATCH 22/24] namei: trim the arguments of get_link() Al Viro
2015-04-20 18:13 ` [PATCH 23/24] new ->follow_link() and ->put_link() calling conventions Al Viro
2015-04-20 18:13 ` [PATCH 24/24] uninline walk_component() Al Viro
2015-04-21 14:49 ` Al Viro [this message]
2015-04-21 15:04   ` [RFC][PATCHSET] non-recursive link_path_walk() and reducing stack footprint Christoph Hellwig
2015-04-21 15:12     ` Richard Weinberger
2015-04-21 15:45       ` Al Viro
2015-04-21 16:46         ` Boaz Harrosh
2015-04-21 21:20         ` Al Viro
2015-04-22 18:07           ` Al Viro
2015-04-22 20:12             ` Al Viro
2015-04-22 21:05               ` Al Viro
2015-04-23  7:45                 ` NeilBrown
2015-04-23 18:07                   ` Al Viro
2015-04-24  6:35                     ` NeilBrown
2015-04-24 13:42                       ` Al Viro
2015-05-04  5:11                         ` Al Viro
2015-05-04  7:30                           ` NeilBrown
2015-04-23  5:01           ` Al Viro
2015-04-21 14:51 ` [PATCH] logfs: fix a pagecache leak for symlinks Al Viro

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=20150421144959.GR889@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=torvalds@linux-foundation.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 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.