btrfs-progs: let corrupt-block kill nbytes
authorDavid Sterba <dsterba@suse.com>
Fri, 3 Jul 2015 16:07:17 +0000 (18:07 +0200)
committerDavid Sterba <dsterba@suse.com>
Fri, 3 Jul 2015 16:07:17 +0000 (18:07 +0200)
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-corrupt-block.c

index 6eb04a7..1a2aa23 100644 (file)
@@ -299,6 +299,7 @@ static void btrfs_corrupt_extent_tree(struct btrfs_trans_handle *trans,
 
 enum btrfs_inode_field {
        BTRFS_INODE_FIELD_ISIZE,
+       BTRFS_INODE_FIELD_NBYTES,
        BTRFS_INODE_FIELD_BAD,
 };
 
@@ -335,6 +336,8 @@ static enum btrfs_inode_field convert_inode_field(char *field)
 {
        if (!strncmp(field, "isize", FIELD_BUF_LEN))
                return BTRFS_INODE_FIELD_ISIZE;
+       if (!strncmp(field, "nbytes", FIELD_BUF_LEN))
+               return BTRFS_INODE_FIELD_NBYTES;
        return BTRFS_INODE_FIELD_BAD;
 }
 
@@ -593,6 +596,11 @@ static int corrupt_inode(struct btrfs_trans_handle *trans,
                bogus = generate_u64(orig);
                btrfs_set_inode_size(path->nodes[0], ei, bogus);
                break;
+       case BTRFS_INODE_FIELD_NBYTES:
+               orig = btrfs_inode_nbytes(path->nodes[0], ei);
+               bogus = generate_u64(orig);
+               btrfs_set_inode_nbytes(path->nodes[0], ei, bogus);
+               break;
        default:
                ret = -EINVAL;
                break;