From: Al Viro <viro@ZenIV.linux.org.uk>
To: Xiaotian Feng <xtfeng@gmail.com>
Cc: tony.luck@intel.com,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [git pull] mnt_devname queue
Date: Thu, 17 Mar 2011 10:44:34 +0000 [thread overview]
Message-ID: <20110317104434.GB22723@ZenIV.linux.org.uk> (raw)
In-Reply-To: <AANLkTin=5jSzZKXLL=A+dbRn1jB+tPg56LmjthzC02ui@mail.gmail.com>
On Thu, Mar 17, 2011 at 03:28:47PM +0800, Xiaotian Feng wrote:
> Cc'ed author ...
>
> > a) What the hell would you expect to happen if userland mounts it twice
> > and unmount the first one? ??pstore_sb = NULL, pstore_mnt = NULL, AFAICS.
BTW, you want
* mount_single(), not mount_nodev()
* simple_pin_fs()/mntput() around modifying that sucker from kernel
(held across both the file creation and writing to it)
> > b) pstore_writefile() - struct file on stack? ??Really? ??Again, in the
> > scenario above, what'll happen to you if pstore_mnt gets dropped and
> > freed in the middle of all that?
> >
> > c) in the same function:
> > + ?? ?? ?? memset(&f, '0', sizeof f);
> > Ahem...
Aside of a new meaning given to "zero that structure out", why the devil
are you doing it in such a convoluted way? Note that you are using ramfs,
so the mapping is unevictable. Simple kmalloc() + memcpy() and
simple_read_from_buffer() to implement ->read() would do nicely.
And for fsck sake, copy ramfs_get_inode() and trim it. You are overriding
it for the single directory in there and you are only using it for regular
files otherwise. With wrong ->i_op and ->i_fop *and* irrelevant messing with
->i_mapping. Which leaves you with
inode->i_ino = get_next_ino();
inode_init_owner(inode, dir, mode);
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
as useful part.
BTW, you want to make the contents visible before d_add(). You
*definitely* want to finish setting it up before unlocking the parent,
or you are asking for userland to come and unlink() it under you.
Incidentally, you are leaking ->i_private on umount. You want ->evict_inode()
doing that kfree(), not ->unlink(). And possibly ->erase() as well, with
check for zero i_nlink around it (in ->evict_inode()).
next prev parent reply other threads:[~2011-03-17 10:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-16 23:56 [git pull] mnt_devname queue Al Viro
2011-03-17 5:45 ` Xiaotian Feng
2011-03-17 7:23 ` Al Viro
2011-03-17 7:28 ` Xiaotian Feng
2011-03-17 10:44 ` Al Viro [this message]
2011-03-17 19:08 ` Tony Luck
2011-03-17 21:35 ` Some fixes for pstore (Was Re: [git pull] mnt_devname queue) Tony Luck
2011-03-17 22:42 ` Al Viro
2011-03-17 22:48 ` Tony Luck
2011-03-17 22:56 ` Al Viro
2011-03-18 18:44 ` pstore: fix leaking ->i_private Luck, Tony
2011-03-18 18:49 ` Christoph Hellwig
2011-03-18 18:55 ` Tony Luck
2011-03-18 22:33 ` pstore: use mount option instead sysfs to tweak kmsg_bytes Luck, Tony
2011-03-18 18:57 ` pstore: fix leaking ->i_private Al Viro
2011-03-17 23:29 ` Some fixes for pstore (Was Re: [git pull] mnt_devname queue) Tony Luck
2011-03-18 0:07 ` 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=20110317104434.GB22723@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=xtfeng@gmail.com \
/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