2014-09-18 06:46:40

by Dexuan Cui

[permalink] [raw]
Subject: RE: Is ext2 freezable?

> -----Original Message-----
> From: Dexuan Cui
> Sent: Thursday, September 18, 2014 13:16 PM
> To: [email protected]
> Subject: Is ext2 freezable?
>
> Hi all,
> I'm running "fsfreeze --freeze /mnt" (/mnt is mounted with an ext2 partition)
> and getting "fsfreeze: /mnt: freeze failed: Operation not supported":
> ...
> code of ioctl_fsfreeze() is:
>
> static int ioctl_fsfreeze(struct file *filp)
> {
> struct super_block *sb = file_inode(filp)->i_sb;
>
> if (!capable(CAP_SYS_ADMIN))
> return -EPERM;
>
> /* If filesystem doesn't support freeze feature, return. */
> if (sb->s_op->freeze_fs == NULL)
> return -EOPNOTSUPP;
>
> /* Freeze */
> return freeze_super(sb);
> }
>
> It seems here sb->s_op->freeze_fs is NULL??? why?

I've got the answer:
ext2.ko itself does support fsfreeze, but typical linux distros don't supply
ext2.ko at all now -- instead, they usually supply ext3.ko and have ext4 builtin.

So when I mount an ext2 partition, actually the kernel is registering the ext4
driver as an ext2 driver and in this case the ext2's s_op->freeze_fs is NULL --
but, why did ext4 choose this behavior for ext2?

Thanks,
-- Dexuan


2014-09-18 19:17:40

by Theodore Ts'o

[permalink] [raw]
Subject: Re: Is ext2 freezable?

On Thu, Sep 18, 2014 at 06:46:21AM +0000, Dexuan Cui wrote:
>
> I've got the answer:
> ext2.ko itself does support fsfreeze, but typical linux distros don't supply
> ext2.ko at all now -- instead, they usually supply ext3.ko and have ext4 builtin.
>
> So when I mount an ext2 partition, actually the kernel is registering the ext4
> driver as an ext2 driver and in this case the ext2's s_op->freeze_fs is NULL --
> but, why did ext4 choose this behavior for ext2?

It wasn't a deliberate design choice. It was just that when
no-journal mode was added to ext4, freeeze support was never
implemented, and up until now, no one had asked for it. We can add it
to ext4; thanks for calling it to our attention.

Cheers,

- Ted

2014-09-19 03:12:28

by Dexuan Cui

[permalink] [raw]
Subject: RE: Is ext2 freezable?

> -----Original Message-----
> From: Theodore Ts'o [mailto:[email protected]]
> Sent: Friday, September 19, 2014 3:18 AM
> To: Dexuan Cui
> Cc: [email protected]
> Subject: Re: Is ext2 freezable?
>
> On Thu, Sep 18, 2014 at 06:46:21AM +0000, Dexuan Cui wrote:
> >
> > I've got the answer:
> > ext2.ko itself does support fsfreeze, but typical linux distros don't supply
> > ext2.ko at all now -- instead, they usually supply ext3.ko and have ext4
> builtin.
> >
> > So when I mount an ext2 partition, actually the kernel is registering the ext4
> > driver as an ext2 driver and in this case the ext2's s_op->freeze_fs is NULL --
> > but, why did ext4 choose this behavior for ext2?
>
> It wasn't a deliberate design choice. It was just that when
> no-journal mode was added to ext4, freeeze support was never
> implemented, and up until now, no one had asked for it. We can add it
> to ext4; thanks for calling it to our attention.
> - Ted

Hi Ted,
Thanks very much for the clarification!

And thanks a lot for implementing this -- I've seen the patches you sent out
several hours ago.

IMO it's useful to have such compatibility, e.g.,
Hyper-V guest has a fsfreeze-based feature to back up the data; the feature
works fine for ext4 partition, but Ubuntu's installer can create /boot
of ext2 partition by default and hence the feature can't work:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1362574

I believe the bug will go away after Ubuntu integrates your patches.

Thanks!
-- Dexuan