"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fs/ext4/ioctl.c" between
linux-3.16.62.tar.xz and linux-3.16.63.tar.xz

About: The full source of the Linux kernel 3.16.x (longterm stable)

ioctl.c  (linux-3.16.62.tar.xz):ioctl.c  (linux-3.16.63.tar.xz)
skipping to change at line 67 skipping to change at line 67
*/ */
static void swap_inode_data(struct inode *inode1, struct inode *inode2) static void swap_inode_data(struct inode *inode1, struct inode *inode2)
{ {
loff_t isize; loff_t isize;
struct ext4_inode_info *ei1; struct ext4_inode_info *ei1;
struct ext4_inode_info *ei2; struct ext4_inode_info *ei2;
ei1 = EXT4_I(inode1); ei1 = EXT4_I(inode1);
ei2 = EXT4_I(inode2); ei2 = EXT4_I(inode2);
memswap(&inode1->i_flags, &inode2->i_flags, sizeof(inode1->i_flags));
memswap(&inode1->i_version, &inode2->i_version, memswap(&inode1->i_version, &inode2->i_version,
sizeof(inode1->i_version)); sizeof(inode1->i_version));
memswap(&inode1->i_blocks, &inode2->i_blocks, memswap(&inode1->i_blocks, &inode2->i_blocks,
sizeof(inode1->i_blocks)); sizeof(inode1->i_blocks));
memswap(&inode1->i_bytes, &inode2->i_bytes, sizeof(inode1->i_bytes)); memswap(&inode1->i_bytes, &inode2->i_bytes, sizeof(inode1->i_bytes));
memswap(&inode1->i_atime, &inode2->i_atime, sizeof(inode1->i_atime)); memswap(&inode1->i_atime, &inode2->i_atime, sizeof(inode1->i_atime));
memswap(&inode1->i_mtime, &inode2->i_mtime, sizeof(inode1->i_mtime)); memswap(&inode1->i_mtime, &inode2->i_mtime, sizeof(inode1->i_mtime));
memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data)); memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data));
memswap(&ei1->i_flags, &ei2->i_flags, sizeof(ei1->i_flags)); memswap(&ei1->i_flags, &ei2->i_flags, sizeof(ei1->i_flags));
skipping to change at line 89 skipping to change at line 88
ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS); ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS);
ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS); ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS);
ext4_es_lru_del(inode1); ext4_es_lru_del(inode1);
ext4_es_lru_del(inode2); ext4_es_lru_del(inode2);
isize = i_size_read(inode1); isize = i_size_read(inode1);
i_size_write(inode1, i_size_read(inode2)); i_size_write(inode1, i_size_read(inode2));
i_size_write(inode2, isize); i_size_write(inode2, isize);
} }
static void reset_inode_seed(struct inode *inode)
{
struct ext4_inode_info *ei = EXT4_I(inode);
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
__le32 inum = cpu_to_le32(inode->i_ino);
__le32 gen = cpu_to_le32(inode->i_generation);
__u32 csum;
if (!ext4_has_metadata_csum(inode->i_sb))
return;
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum, sizeof(inum));
ei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen, sizeof(gen));
}
/** /**
* Swap the information from the given @inode and the inode * Swap the information from the given @inode and the inode
* EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other * EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other
* important fields of the inodes. * important fields of the inodes.
* *
* @sb: the super block of the filesystem * @sb: the super block of the filesystem
* @inode: the inode to swap with EXT4_BOOT_LOADER_INO * @inode: the inode to swap with EXT4_BOOT_LOADER_INO
* *
*/ */
static long swap_inode_boot_loader(struct super_block *sb, static long swap_inode_boot_loader(struct super_block *sb,
struct inode *inode) struct inode *inode)
{ {
handle_t *handle; handle_t *handle;
int err; int err;
struct inode *inode_bl; struct inode *inode_bl;
struct ext4_inode_info *ei_bl; struct ext4_inode_info *ei_bl;
struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_sb_info *sbi = EXT4_SB(sb);
if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode) ||
IS_SWAPFILE(inode) ||
ext4_has_inline_data(inode))
return -EINVAL; return -EINVAL;
if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) if (IS_RDONLY(inode) || IS_APPEND(inode) || IS_IMMUTABLE(inode) ||
!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO); inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO);
if (IS_ERR(inode_bl)) if (IS_ERR(inode_bl))
return PTR_ERR(inode_bl); return PTR_ERR(inode_bl);
ei_bl = EXT4_I(inode_bl); ei_bl = EXT4_I(inode_bl);
filemap_flush(inode->i_mapping); filemap_flush(inode->i_mapping);
filemap_flush(inode_bl->i_mapping); filemap_flush(inode_bl->i_mapping);
/* Protect orig inodes against a truncate and make sure, /* Protect orig inodes against a truncate and make sure,
* that only 1 swap_inode_boot_loader is running. */ * that only 1 swap_inode_boot_loader is running. */
lock_two_nondirectories(inode, inode_bl); lock_two_nondirectories(inode, inode_bl);
truncate_inode_pages(&inode->i_data, 0);
truncate_inode_pages(&inode_bl->i_data, 0);
/* Wait for all existing dio workers */ /* Wait for all existing dio workers */
ext4_inode_block_unlocked_dio(inode); ext4_inode_block_unlocked_dio(inode);
ext4_inode_block_unlocked_dio(inode_bl); ext4_inode_block_unlocked_dio(inode_bl);
inode_dio_wait(inode); inode_dio_wait(inode);
inode_dio_wait(inode_bl); inode_dio_wait(inode_bl);
truncate_inode_pages(&inode->i_data, 0);
truncate_inode_pages(&inode_bl->i_data, 0);
handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2); handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
err = -EINVAL; err = -EINVAL;
goto journal_err_out; goto journal_err_out;
} }
/* Protect extent tree against block allocations via delalloc */ /* Protect extent tree against block allocations via delalloc */
ext4_double_down_write_data_sem(inode, inode_bl); ext4_double_down_write_data_sem(inode, inode_bl);
if (inode_bl->i_nlink == 0) { if (inode_bl->i_nlink == 0) {
skipping to change at line 169 skipping to change at line 186
} }
swap_inode_data(inode, inode_bl); swap_inode_data(inode, inode_bl);
inode->i_ctime = inode_bl->i_ctime = ext4_current_time(inode); inode->i_ctime = inode_bl->i_ctime = ext4_current_time(inode);
spin_lock(&sbi->s_next_gen_lock); spin_lock(&sbi->s_next_gen_lock);
inode->i_generation = sbi->s_next_generation++; inode->i_generation = sbi->s_next_generation++;
inode_bl->i_generation = sbi->s_next_generation++; inode_bl->i_generation = sbi->s_next_generation++;
spin_unlock(&sbi->s_next_gen_lock); spin_unlock(&sbi->s_next_gen_lock);
reset_inode_seed(inode);
reset_inode_seed(inode_bl);
ext4_discard_preallocations(inode); ext4_discard_preallocations(inode);
err = ext4_mark_inode_dirty(handle, inode); err = ext4_mark_inode_dirty(handle, inode);
if (err < 0) { if (err < 0) {
ext4_warning(inode->i_sb, ext4_warning(inode->i_sb,
"couldn't mark inode #%lu dirty (err %d)", "couldn't mark inode #%lu dirty (err %d)",
inode->i_ino, err); inode->i_ino, err);
/* Revert all changes: */ /* Revert all changes: */
swap_inode_data(inode, inode_bl); swap_inode_data(inode, inode_bl);
ext4_mark_inode_dirty(handle, inode);
} else { } else {
err = ext4_mark_inode_dirty(handle, inode_bl); err = ext4_mark_inode_dirty(handle, inode_bl);
if (err < 0) { if (err < 0) {
ext4_warning(inode_bl->i_sb, ext4_warning(inode_bl->i_sb,
"couldn't mark inode #%lu dirty (err %d)", "couldn't mark inode #%lu dirty (err %d)",
inode_bl->i_ino, err); inode_bl->i_ino, err);
/* Revert all changes: */ /* Revert all changes: */
swap_inode_data(inode, inode_bl); swap_inode_data(inode, inode_bl);
ext4_mark_inode_dirty(handle, inode); ext4_mark_inode_dirty(handle, inode);
ext4_mark_inode_dirty(handle, inode_bl);
} }
} }
ext4_journal_stop(handle); ext4_journal_stop(handle);
ext4_double_up_write_data_sem(inode, inode_bl); ext4_double_up_write_data_sem(inode, inode_bl);
journal_err_out: journal_err_out:
ext4_inode_resume_unlocked_dio(inode); ext4_inode_resume_unlocked_dio(inode);
ext4_inode_resume_unlocked_dio(inode_bl); ext4_inode_resume_unlocked_dio(inode_bl);
unlock_two_nondirectories(inode, inode_bl); unlock_two_nondirectories(inode, inode_bl);
iput(inode_bl); iput(inode_bl);
 End of changes. 9 change blocks. 
6 lines changed or deleted 27 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)