Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1666207
| From | Richard Narron <comet.berkeley@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [git pull] first batch of ufs fixes |
| Date | 2017-06-14 22:40 +0200 |
| Message-ID | <tSnf3-1rl-15@gated-at.bofh.it> (permalink) |
| References | (5 earlier) <tRqRI-6Wp-9@gated-at.bofh.it> <tRIlz-10C-9@gated-at.bofh.it> <tRJ7Y-1wv-3@gated-at.bofh.it> <tS20V-4RM-3@gated-at.bofh.it> <tSaKS-2aJ-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, 14 Jun 2017, Al Viro wrote:
...
> AFAICS, a conservative approach would be
> * reject UFS_42POSTBLFMT for 44bsd ones - it's almost certainly
> *not* one.
> * check if fs_maxbsize is equal to frag size; treat that as
> "counts are read from new location and stored both to old and new".
> 44bsd fs_maxbsize != block size => not converted, just use old locations
> for everything. UFS2 => use new locations for everything, don't bother
> with old ones. IOW, something like this (WARNING: completely untested,
> might screw your filesystem) might do.
>
> NOTE: all I have is your image *after* it had counters buggered; I don't
> know the exact sequence of operations that fucked it in your case. One
> way to trigger it is to mount/umount on OpenBSD, then mount/modify/umount
> on Linux, then mount/umount on OpenBSD, then fsck on OpenBSD. This patch
> apparently fixes that, but your reproducer might be something different.
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
> diff --git a/fs/ufs/super.c b/fs/ufs/super.c
> index d9aa2627c9df..eca838a8b43e 100644
> --- a/fs/ufs/super.c
> +++ b/fs/ufs/super.c
> @@ -480,7 +480,7 @@ static void ufs_setup_cstotal(struct super_block *sb)
> usb3 = ubh_get_usb_third(uspi);
>
> if ((mtype == UFS_MOUNT_UFSTYPE_44BSD &&
> - (usb1->fs_flags & UFS_FLAGS_UPDATED)) ||
> + (usb2->fs_un.fs_u2.fs_maxbsize == usb1->fs_bsize)) ||
> mtype == UFS_MOUNT_UFSTYPE_UFS2) {
> /*we have statistic in different place, then usual*/
> uspi->cs_total.cs_ndir = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir);
> @@ -596,9 +596,7 @@ static void ufs_put_cstotal(struct super_block *sb)
> usb2 = ubh_get_usb_second(uspi);
> usb3 = ubh_get_usb_third(uspi);
>
> - if ((mtype == UFS_MOUNT_UFSTYPE_44BSD &&
> - (usb1->fs_flags & UFS_FLAGS_UPDATED)) ||
> - mtype == UFS_MOUNT_UFSTYPE_UFS2) {
> + if (mtype == UFS_MOUNT_UFSTYPE_UFS2) {
> /*we have statistic in different place, then usual*/
> usb2->fs_un.fs_u2.cs_ndir =
> cpu_to_fs64(sb, uspi->cs_total.cs_ndir);
> @@ -608,16 +606,26 @@ static void ufs_put_cstotal(struct super_block *sb)
> cpu_to_fs64(sb, uspi->cs_total.cs_nifree);
> usb3->fs_un1.fs_u2.cs_nffree =
> cpu_to_fs64(sb, uspi->cs_total.cs_nffree);
> - } else {
> - usb1->fs_cstotal.cs_ndir =
> - cpu_to_fs32(sb, uspi->cs_total.cs_ndir);
> - usb1->fs_cstotal.cs_nbfree =
> - cpu_to_fs32(sb, uspi->cs_total.cs_nbfree);
> - usb1->fs_cstotal.cs_nifree =
> - cpu_to_fs32(sb, uspi->cs_total.cs_nifree);
> - usb1->fs_cstotal.cs_nffree =
> - cpu_to_fs32(sb, uspi->cs_total.cs_nffree);
> + goto out;
> }
> +
> + if (mtype == UFS_MOUNT_UFSTYPE_44BSD &&
> + (usb2->fs_un.fs_u2.fs_maxbsize == usb1->fs_bsize)) {
> + /* store stats in both old and new places */
> + usb2->fs_un.fs_u2.cs_ndir =
> + cpu_to_fs64(sb, uspi->cs_total.cs_ndir);
> + usb2->fs_un.fs_u2.cs_nbfree =
> + cpu_to_fs64(sb, uspi->cs_total.cs_nbfree);
> + usb3->fs_un1.fs_u2.cs_nifree =
> + cpu_to_fs64(sb, uspi->cs_total.cs_nifree);
> + usb3->fs_un1.fs_u2.cs_nffree =
> + cpu_to_fs64(sb, uspi->cs_total.cs_nffree);
> + }
> + usb1->fs_cstotal.cs_ndir = cpu_to_fs32(sb, uspi->cs_total.cs_ndir);
> + usb1->fs_cstotal.cs_nbfree = cpu_to_fs32(sb, uspi->cs_total.cs_nbfree);
> + usb1->fs_cstotal.cs_nifree = cpu_to_fs32(sb, uspi->cs_total.cs_nifree);
> + usb1->fs_cstotal.cs_nffree = cpu_to_fs32(sb, uspi->cs_total.cs_nffree);
> +out:
> ubh_mark_buffer_dirty(USPI_UBH(uspi));
> ufs_print_super_stuff(sb, usb1, usb2, usb3);
> UFSD("EXIT\n");
> @@ -997,6 +1005,13 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
> flags |= UFS_ST_SUN;
> }
>
> + if ((flags & UFS_ST_MASK) == UFS_ST_44BSD &&
> + uspi->s_postblformat == UFS_42POSTBLFMT) {
> + if (!silent)
> + pr_err("this is not a 44bsd filesystem");
> + goto failed;
> + }
> +
> /*
> * Check ufs magic number
> */
>
Al this patch looks good to me (so far). I tested all 6 combinations of
ufs1 and ufs2 in FreeBSD 11.0, OpenBSD 6.1 and NetBSD 7.1
For each combination, I do 5 steps:
1) BSD: Make a ufs filesystem
dd if=/dev/zero to the BSD subpartition
make (newfs) a ufs (1 or 2) filesystem on the BSD subpartiton
2) Linux: Create a subdirectory and make a large file
mkdir a
dd if=/dev/zero bs=1M count=3072
3) BSD: Check a ufs filesystem
fsck -f
4) Linux: Remove the large file and the subdirectory
rm
rmdir
5) BSD; check a ufs filesystem
fsck -f
Tested-By: Richard Narron <comet.berkeley@gmail.com>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-09 23:40 +0200
Re: [git pull] first batch of ufs fixes Richard Narron <comet.berkeley@gmail.com> - 2017-06-10 15:10 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-10 18:10 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-10 20:10 +0200
Re: [git pull] first batch of ufs fixes Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-10 20:20 +0200
Re: [git pull] first batch of ufs fixes Richard Narron <comet.berkeley@gmail.com> - 2017-06-11 21:50 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-11 23:40 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-12 08:20 +0200
Re: [git pull] first batch of ufs fixes Richard Narron <comet.berkeley@gmail.com> - 2017-06-13 03:00 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-13 03:50 +0200
Re: [git pull] first batch of ufs fixes Richard Narron <comet.berkeley@gmail.com> - 2017-06-14 00:00 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-14 09:20 +0200
Re: [git pull] first batch of ufs fixes Richard Narron <comet.berkeley@gmail.com> - 2017-06-14 22:40 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-15 10:10 +0200
Re: [git pull] first batch of ufs fixes Richard Narron <comet.berkeley@gmail.com> - 2017-06-16 16:30 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-17 04:20 +0200
Re: [git pull] first batch of ufs fixes Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-18 03:20 +0200
Re: [git pull] first batch of ufs fixes Richard Narron <comet.berkeley@gmail.com> - 2017-06-18 22:50 +0200
csiph-web