Whamcloud - gitweb
tune2fs: remove_journal_device(): use the correct block to find jsb
authorAzat Khuzhin <a3at.mail@gmail.com>
Mon, 28 Jul 2014 07:43:23 +0000 (11:43 +0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 29 Jul 2014 00:21:59 +0000 (20:21 -0400)
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/tune2fs.c

index ff50f37..1df655a 100644 (file)
@@ -188,6 +188,7 @@ static int remove_journal_device(ext2_filsys fs)
        errcode_t       retval;
        int             commit_remove_journal = 0;
        io_manager      io_ptr;
+       int start;
 
        if (f_flag)
                commit_remove_journal = 1; /* force removal even if error */
@@ -224,8 +225,10 @@ static int remove_journal_device(ext2_filsys fs)
                goto no_valid_journal;
        }
 
+       start = ext2fs_journal_sb_start(fs->blocksize);
        /* Get the journal superblock */
-       if ((retval = io_channel_read_blk64(jfs->io, 1, -SUPERBLOCK_SIZE, buf))) {
+       if ((retval = io_channel_read_blk64(jfs->io, start,
+           -SUPERBLOCK_SIZE, buf))) {
                com_err(program_name, retval, "%s",
                        _("while reading journal superblock"));
                goto no_valid_journal;
@@ -256,7 +259,8 @@ static int remove_journal_device(ext2_filsys fs)
        jsb->s_nr_users = htonl(nr_users);
 
        /* Write back the journal superblock */
-       if ((retval = io_channel_write_blk64(jfs->io, 1, -SUPERBLOCK_SIZE, buf))) {
+       if ((retval = io_channel_write_blk64(jfs->io, start,
+           -SUPERBLOCK_SIZE, buf))) {
                com_err(program_name, retval,
                        "while writing journal superblock.");
                goto no_valid_journal;