resize.c (19c5246d251640ac76daa4d34165af78c64b1454) | resize.c (d89651c8e222b2d2797bf66d4eb7064459f4f4f4) |
---|---|
1/* 2 * linux/fs/ext4/resize.c 3 * 4 * Support for resizing an ext4 filesystem while it is mounted. 5 * 6 * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com> 7 * 8 * This could probably be made into a module, because it is not often in use. --- 1781 unchanged lines hidden (view full) --- 1790 */ 1791int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, 1792 ext4_fsblk_t n_blocks_count) 1793{ 1794 ext4_fsblk_t o_blocks_count; 1795 ext4_grpblk_t last; 1796 ext4_grpblk_t add; 1797 struct buffer_head *bh; | 1/* 2 * linux/fs/ext4/resize.c 3 * 4 * Support for resizing an ext4 filesystem while it is mounted. 5 * 6 * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com> 7 * 8 * This could probably be made into a module, because it is not often in use. --- 1781 unchanged lines hidden (view full) --- 1790 */ 1791int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, 1792 ext4_fsblk_t n_blocks_count) 1793{ 1794 ext4_fsblk_t o_blocks_count; 1795 ext4_grpblk_t last; 1796 ext4_grpblk_t add; 1797 struct buffer_head *bh; |
1798 handle_t *handle; 1799 int err, err2; | 1798 int err; |
1800 ext4_group_t group; 1801 1802 o_blocks_count = ext4_blocks_count(es); 1803 1804 if (test_opt(sb, DEBUG)) 1805 printk(KERN_DEBUG "EXT4-fs: extending last group from %llu to %llu blocks\n", 1806 o_blocks_count, n_blocks_count); 1807 --- 39 unchanged lines hidden (view full) --- 1847 /* See if the device is actually as big as what was requested */ 1848 bh = sb_bread(sb, o_blocks_count + add - 1); 1849 if (!bh) { 1850 ext4_warning(sb, "can't read last block, resize aborted"); 1851 return -ENOSPC; 1852 } 1853 brelse(bh); 1854 | 1799 ext4_group_t group; 1800 1801 o_blocks_count = ext4_blocks_count(es); 1802 1803 if (test_opt(sb, DEBUG)) 1804 printk(KERN_DEBUG "EXT4-fs: extending last group from %llu to %llu blocks\n", 1805 o_blocks_count, n_blocks_count); 1806 --- 39 unchanged lines hidden (view full) --- 1846 /* See if the device is actually as big as what was requested */ 1847 bh = sb_bread(sb, o_blocks_count + add - 1); 1848 if (!bh) { 1849 ext4_warning(sb, "can't read last block, resize aborted"); 1850 return -ENOSPC; 1851 } 1852 brelse(bh); 1853 |
1855 /* We will update the superblock, one block bitmap, and 1856 * one group descriptor via ext4_free_blocks(). 1857 */ 1858 handle = ext4_journal_start_sb(sb, 3); 1859 if (IS_ERR(handle)) { 1860 err = PTR_ERR(handle); 1861 ext4_warning(sb, "error %d on journal start", err); 1862 goto exit_put; 1863 } 1864 1865 if ((err = ext4_journal_get_write_access(handle, 1866 EXT4_SB(sb)->s_sbh))) { 1867 ext4_warning(sb, "error %d on journal write access", err); 1868 ext4_journal_stop(handle); 1869 goto exit_put; 1870 } 1871 ext4_blocks_count_set(es, o_blocks_count + add); 1872 ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count, 1873 o_blocks_count + add); 1874 /* We add the blocks to the bitmap and set the group need init bit */ 1875 err = ext4_group_add_blocks(handle, sb, o_blocks_count, add); 1876 ext4_handle_dirty_super(handle, sb); 1877 ext4_debug("freed blocks %llu through %llu\n", o_blocks_count, 1878 o_blocks_count + add); 1879 err2 = ext4_journal_stop(handle); 1880 if (!err && err2) 1881 err = err2; 1882 1883 if (err) 1884 goto exit_put; 1885 1886 if (test_opt(sb, DEBUG)) 1887 printk(KERN_DEBUG "EXT4-fs: extended group to %llu blocks\n", 1888 ext4_blocks_count(es)); 1889 update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr, (char *)es, 1890 sizeof(struct ext4_super_block)); 1891exit_put: | 1854 err = ext4_group_extend_no_check(sb, o_blocks_count, add); |
1892 return err; 1893} /* ext4_group_extend */ 1894 1895/* 1896 * ext4_resize_fs() resizes a fs to new size specified by @n_blocks_count 1897 * 1898 * @sb: super block of the fs to be resized 1899 * @n_blocks_count: the number of blocks resides in the resized fs --- 107 unchanged lines hidden --- | 1855 return err; 1856} /* ext4_group_extend */ 1857 1858/* 1859 * ext4_resize_fs() resizes a fs to new size specified by @n_blocks_count 1860 * 1861 * @sb: super block of the fs to be resized 1862 * @n_blocks_count: the number of blocks resides in the resized fs --- 107 unchanged lines hidden --- |