All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] fs: record task name which froze superblock
Date: Fri, 20 Feb 2015 13:15:22 +0100	[thread overview]
Message-ID: <20150220121522.GC6293@quack.suse.cz> (raw)
In-Reply-To: <CACVxJT9E7Z5Q4=F1bOEXiZ4rrWFrm5_X0Hcj-oHP-Jach8gBXw@mail.gmail.com>

On Fri 20-02-15 14:42:29, Alexey Dobriyan wrote:
> On Wed, Feb 18, 2015 at 12:13 PM, Jan Kara <jack@suse.cz> wrote:
> >> > > --- a/fs/ioctl.c
> >> > > +++ b/fs/ioctl.c
> >> > > @@ -518,6 +518,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp,
> >> > >  static int ioctl_fsfreeze(struct file *filp)
> >> > >  {
> >> > >   struct super_block *sb = file_inode(filp)->i_sb;
> >> > > + int rv;
> >> > >
> >> > >   if (!capable(CAP_SYS_ADMIN))
> >> > >           return -EPERM;
> >> > > @@ -527,22 +528,31 @@ static int ioctl_fsfreeze(struct file *filp)
> >> > >           return -EOPNOTSUPP;
> >> > >
> >> > >   /* Freeze */
> >> > > - if (sb->s_op->freeze_super)
> >> > > -         return sb->s_op->freeze_super(sb);
> >> > > - return freeze_super(sb);
> >> > > + if (sb->s_op->freeze_super) {
> >> > > +         rv = sb->s_op->freeze_super(sb);
> >> > > +         if (rv == 0)
> >> > > +                 get_task_comm(sb->s_writers.freeze_comm, current);
> >> > > + } else
> >> > > +         rv = freeze_super(sb);
> >> > > + return rv;
> >> >   Why don't you just set the name in ioctl_fsfreeze() in both cases?
> >>
> >> There are users of freeze_super() in GFS2 unless I'm misreading code.
> >   Yes, there are. The call in fs/gfs2/glops.c is in a call path from
> > ->freeze_super() handler for GFS2 so that one is handled in
> > ioctl_fsfreeze() anyway. The call in fs/gfs2/sys.c is a way to freeze
> > filesystem via sysfs (dunno why GFS2 has to invent its own thing and ioctl
> > isn't enough). Steven? So having the logic in ioctl_fsfreeze(),
> > freeze_bdev() and freeze_store() in gfs2 seems to be enough.
> 
> Jan, my logic is as follows.
> 
> Recording freezer task name is not filesystem/device specific and
> thus should be done in generic code. So no changes in GFS2.
> 
> freeze_super() is generic counterpart to filesystem/device
> specific ->freeze_super() hook, look how they are paired.
> It should recore freezer task name, so any future user
> will not forget to do the same.
> 
> So it's in ioctl_fsfreeze(), freeze_bdev() and freeze_super().
  Well, but this stores the name in two different levels - once in the top
level (ioctl_fsfreeze(), freeze_bdev()) and once in a place called from
there (freeze_super()). That just seems wrong to me. You can just record
the frozen process in freeze_super() and mandate that if someone manages to
freeze the fs without calling freeze_super() from his ->freeze_super()
handler (currently there isn't such filesystem), he is also responsible for
setting freezer name... Hmm?

> >> > > --- a/include/linux/fs.h
> >> > > +++ b/include/linux/fs.h
> >> > > @@ -1221,6 +1221,8 @@ struct sb_writers {
> >> > >   int                     frozen;         /* Is sb frozen? */
> >> > >   wait_queue_head_t       wait_unfrozen;  /* queue for waiting for
> >> > >                                              sb to be thawed */
> >> > > + /* who froze superblock */
> >> > > + char                    freeze_comm[16];
> >> >   Here should be TASK_COMM_LEN, shouldn't it?
> >>
> >> It will pull sched.h, dunno if we care about headers anymore.
> >   That's not ideal but IMHO better than having the value hardcoded here.
> > That is pretty fragile - i.e. think what happens when someone decides to
> > increase TASK_COMM_LEN...
> 
> TASK_COMM_LEN is userspace ABI via at least prctl(PR_SET_NAME).
> I can formally move it to include/uapi/linux/sched.h.
> This allows to not drag sched.h into fs.h for one tiny define.
  OK, moving the definition would be preferable to me (and IMO also a
cleanup).

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR



WARNING: multiple messages have this Message-ID (diff)
From: Jan Kara <jack@suse.cz>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	swhiteho@redhat.com, cluster-devel@redhat.com
Subject: Re: [PATCH] fs: record task name which froze superblock
Date: Fri, 20 Feb 2015 13:15:22 +0100	[thread overview]
Message-ID: <20150220121522.GC6293@quack.suse.cz> (raw)
In-Reply-To: <CACVxJT9E7Z5Q4=F1bOEXiZ4rrWFrm5_X0Hcj-oHP-Jach8gBXw@mail.gmail.com>

On Fri 20-02-15 14:42:29, Alexey Dobriyan wrote:
> On Wed, Feb 18, 2015 at 12:13 PM, Jan Kara <jack@suse.cz> wrote:
> >> > > --- a/fs/ioctl.c
> >> > > +++ b/fs/ioctl.c
> >> > > @@ -518,6 +518,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp,
> >> > >  static int ioctl_fsfreeze(struct file *filp)
> >> > >  {
> >> > >   struct super_block *sb = file_inode(filp)->i_sb;
> >> > > + int rv;
> >> > >
> >> > >   if (!capable(CAP_SYS_ADMIN))
> >> > >           return -EPERM;
> >> > > @@ -527,22 +528,31 @@ static int ioctl_fsfreeze(struct file *filp)
> >> > >           return -EOPNOTSUPP;
> >> > >
> >> > >   /* Freeze */
> >> > > - if (sb->s_op->freeze_super)
> >> > > -         return sb->s_op->freeze_super(sb);
> >> > > - return freeze_super(sb);
> >> > > + if (sb->s_op->freeze_super) {
> >> > > +         rv = sb->s_op->freeze_super(sb);
> >> > > +         if (rv == 0)
> >> > > +                 get_task_comm(sb->s_writers.freeze_comm, current);
> >> > > + } else
> >> > > +         rv = freeze_super(sb);
> >> > > + return rv;
> >> >   Why don't you just set the name in ioctl_fsfreeze() in both cases?
> >>
> >> There are users of freeze_super() in GFS2 unless I'm misreading code.
> >   Yes, there are. The call in fs/gfs2/glops.c is in a call path from
> > ->freeze_super() handler for GFS2 so that one is handled in
> > ioctl_fsfreeze() anyway. The call in fs/gfs2/sys.c is a way to freeze
> > filesystem via sysfs (dunno why GFS2 has to invent its own thing and ioctl
> > isn't enough). Steven? So having the logic in ioctl_fsfreeze(),
> > freeze_bdev() and freeze_store() in gfs2 seems to be enough.
> 
> Jan, my logic is as follows.
> 
> Recording freezer task name is not filesystem/device specific and
> thus should be done in generic code. So no changes in GFS2.
> 
> freeze_super() is generic counterpart to filesystem/device
> specific ->freeze_super() hook, look how they are paired.
> It should recore freezer task name, so any future user
> will not forget to do the same.
> 
> So it's in ioctl_fsfreeze(), freeze_bdev() and freeze_super().
  Well, but this stores the name in two different levels - once in the top
level (ioctl_fsfreeze(), freeze_bdev()) and once in a place called from
there (freeze_super()). That just seems wrong to me. You can just record
the frozen process in freeze_super() and mandate that if someone manages to
freeze the fs without calling freeze_super() from his ->freeze_super()
handler (currently there isn't such filesystem), he is also responsible for
setting freezer name... Hmm?

> >> > > --- a/include/linux/fs.h
> >> > > +++ b/include/linux/fs.h
> >> > > @@ -1221,6 +1221,8 @@ struct sb_writers {
> >> > >   int                     frozen;         /* Is sb frozen? */
> >> > >   wait_queue_head_t       wait_unfrozen;  /* queue for waiting for
> >> > >                                              sb to be thawed */
> >> > > + /* who froze superblock */
> >> > > + char                    freeze_comm[16];
> >> >   Here should be TASK_COMM_LEN, shouldn't it?
> >>
> >> It will pull sched.h, dunno if we care about headers anymore.
> >   That's not ideal but IMHO better than having the value hardcoded here.
> > That is pretty fragile - i.e. think what happens when someone decides to
> > increase TASK_COMM_LEN...
> 
> TASK_COMM_LEN is userspace ABI via at least prctl(PR_SET_NAME).
> I can formally move it to include/uapi/linux/sched.h.
> This allows to not drag sched.h into fs.h for one tiny define.
  OK, moving the definition would be preferable to me (and IMO also a
cleanup).

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

  reply	other threads:[~2015-02-20 12:15 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-14 18:55 [Cluster-devel] [PATCH] fs: record task name which froze superblock Alexey Dobriyan
2015-02-14 18:55 ` Alexey Dobriyan
2015-02-16  9:38 ` [Cluster-devel] " Jan Kara
2015-02-16  9:38   ` Jan Kara
2015-02-18  7:34   ` [Cluster-devel] " Alexey Dobriyan
2015-02-18  7:34     ` Alexey Dobriyan
2015-02-18  7:36     ` [Cluster-devel] [PATCH v2] " Alexey Dobriyan
2015-02-18  7:36       ` Alexey Dobriyan
2015-02-18  9:13     ` [Cluster-devel] [PATCH] " Jan Kara
2015-02-18  9:13       ` Jan Kara
2015-02-18 10:18       ` [Cluster-devel] " Steven Whitehouse
2015-02-18 10:18         ` Steven Whitehouse
2015-02-20 11:42       ` [Cluster-devel] " Alexey Dobriyan
2015-02-20 11:42         ` Alexey Dobriyan
2015-02-20 12:15         ` Jan Kara [this message]
2015-02-20 12:15           ` Jan Kara
2015-02-28 14:22           ` [Cluster-devel] " Alexey Dobriyan
2015-02-28 14:22             ` Alexey Dobriyan
2015-02-28 14:25             ` [Cluster-devel] [PATCH v3] " Alexey Dobriyan
2015-02-28 14:25               ` Alexey Dobriyan
2015-02-28 21:31               ` [Cluster-devel] " Dave Chinner
2015-02-28 21:31                 ` Dave Chinner
2015-03-02  4:38                 ` [Cluster-devel] " Mateusz Guzik
2015-03-02  4:38                   ` Mateusz Guzik
2015-03-02  4:46                   ` [Cluster-devel] " Mateusz Guzik
2015-03-02  4:46                     ` Mateusz Guzik
2015-03-09 15:14                     ` [Cluster-devel] " Alexey Dobriyan
2015-03-09 15:14                       ` Alexey Dobriyan
2015-03-02 21:33                   ` [Cluster-devel] " Dave Chinner
2015-03-02 21:33                     ` Dave Chinner
2015-03-04 15:14                   ` [Cluster-devel] " Alexey Dobriyan
2015-03-04 15:14                     ` Alexey Dobriyan

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=20150220121522.GC6293@quack.suse.cz \
    --to=jack@suse.cz \
    /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.