Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1380545 > unrolled thread
| Started by | Florian Margaine <florian@margaine.com> |
|---|---|
| First post | 2016-04-16 14:20 +0200 |
| Last post | 2016-04-17 21:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] fs: add the FIGETFROZEN ioctl call Florian Margaine <florian@margaine.com> - 2016-04-16 14:20 +0200
Re: [PATCH] fs: add the FIGETFROZEN ioctl call Jan Kara <jack@suse.cz> - 2016-04-17 21:20 +0200
| From | Florian Margaine <florian@margaine.com> |
|---|---|
| Date | 2016-04-16 14:20 +0200 |
| Subject | Re: [PATCH] fs: add the FIGETFROZEN ioctl call |
| Message-ID | <roxmG-3g1-3@gated-at.bofh.it> |
On Fri, 2016-04-15 at 12:17 +1000, Dave Chinner wrote:
> On Thu, Apr 14, 2016 at 09:57:07AM +0200, Florian Margaine wrote:
> > This lets userland get the filesystem freezing status, aka whether
> > the
> > filesystem is frozen or not. This is so that an application can
> > know if
> > it should freeze the filesystem or if it isn't necessary when
> > taking a
> > snapshot.
>
> freezing nests, so there is no reason for avoiding a freeze when
> doing a snapshot. Indeed, if you don't wrap freeze/thaw around a
> snapshot, then if the fs is thawed while the snapshot is in progress
> then you are going to get a corrupt snapshot....
>
> And, besides, polling for frozenness from userspace is inherently
> racy - by the time the syscall returns, the information may be
> incorrect, so you can't rely on it for decision making purposes in
> userspace.
The example I have is mostly about unfreezing. If I freeze, make a
snapshot, then unfreeze. If my program crashes after the
snapshot/before unfreezing, I'll be left with a frozen filesystem,
which is undesirable, at best.
One way to mitigate this is to keep the state of the snapshot, but it
seems silly to keep this information separately (e.g. in a database)
when the kernel has it available.
>
> > +static int ioctl_fsgetfrozen(struct file *filp)
> > +{
> > + struct super_block *sb = file_inode(filp)->i_sb;
> > +
> > + if (!capable(CAP_SYS_ADMIN))
> > + return -EPERM;
> > +
> > + return sb->s_writers.frozen;
>
> This makes the internal freeze implementation states part of the
> userspace ABI. This needs an API that is separate from the internal
> implementation...
I'm not sure I understand, do you mean it should be e.g.:
return sb->s_writers.frozen ? 1 : 0;
?
>
> Cheers,
>
> Dave.
Regards,
Florian
[toc] | [next] | [standalone]
| From | Jan Kara <jack@suse.cz> |
|---|---|
| Date | 2016-04-17 21:20 +0200 |
| Message-ID | <rp0oG-SM-5@gated-at.bofh.it> |
| In reply to | #1380545 |
On Sat 16-04-16 14:18:19, Florian Margaine wrote: > On Fri, 2016-04-15 at 12:17 +1000, Dave Chinner wrote: > > On Thu, Apr 14, 2016 at 09:57:07AM +0200, Florian Margaine wrote: > > > This lets userland get the filesystem freezing status, aka whether > > > the > > > filesystem is frozen or not. This is so that an application can > > > know if > > > it should freeze the filesystem or if it isn't necessary when > > > taking a > > > snapshot. > > > > freezing nests, so there is no reason for avoiding a freeze when > > doing a snapshot. Indeed, if you don't wrap freeze/thaw around a > > snapshot, then if the fs is thawed while the snapshot is in progress > > then you are going to get a corrupt snapshot.... > > > > And, besides, polling for frozenness from userspace is inherently > > racy - by the time the syscall returns, the information may be > > incorrect, so you can't rely on it for decision making purposes in > > userspace. > > The example I have is mostly about unfreezing. If I freeze, make a > snapshot, then unfreeze. If my program crashes after the > snapshot/before unfreezing, I'll be left with a frozen filesystem, > which is undesirable, at best. > > One way to mitigate this is to keep the state of the snapshot, but it > seems silly to keep this information separately (e.g. in a database) > when the kernel has it available. Well, administrator can always unfreeze manually if he sees some glitch like you described above has happened. And as Dave said, the interface you propose is racy - how would you recognize the following two situations? 1) Your app has crashed with frozen fs. 2) Some other application is just snapshotting the fs and will unfreeze it eventually. In the first case you need additional thaw, in the second case you must not thaw the fs. That's why we kept the decision about thawing the fs to the administrator... Honza -- Jan Kara <jack@suse.com> SUSE Labs, CR
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web