Revert a potential seek_data/hole regression which shows up when using
ext4 to handle ext3 file systems, plus two minor bug fixes. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJUqxTQAAoJENNvdpvBGATwUC8QAIYfP02XYyGrBQIoAoCiRJji TmhAe2Amy9xHgBq2I8Yz3bi8j1wGuiqc57fYgwwVScf10tzmO/HuwnAZZDAmg9hK ZWp9WyPoyf+U/nbkIfC5mRh3Qz0dt1pt6R3uQDUlcUuAamdMBrdJnhkQC6WMbpU2 fAqsJT3/yGrLnMF29eVqJzcxb5KORJ8hEcD7kwkvJwe4sGm3C7iDsjS0i63YWDz4 QNclW6zF4THhmuVNxwRupOgMQNSq8sHg8U23nP4DZLvLE7GlgtwfDvehU7uBfw5n WO5UfsEYLoeODNmujUJCtjXNLpzDXmrtByyWbbTK7EX3MmV94ym4uu5lHLfyMiTc o2ppxcsKBVcOsPWnFwuhJ5p/Wyy0Uld9Q3P6b5ymhyzDhkuwcTURpeRxBRXHEgcm nY5GE1bBdO7OigDz/+DFL/Zgr8EO7hW72hrBaLDWMEbrrl0asZw/ReC/bnreMmm4 sP87DB+MqRXzRs8aOPWmCofJwGSgCYmOq2nqNCAaxgk/ofvrDURrnZYfLrbzspGa hqE1W0X5hvQydcifi4qq2Na76+Js3atSY38EOH/HNknSqlQjysnkW4ajTDWk/GFy M/fKUCfIl1tmCMN2myZzl89E7uMSyod75ycd0BQy36iHPE14JVvk/u7GfcKHLs53 1rAPpW90a72GX2Z9+xxA =uPYz -----END PGP SIGNATURE----- Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 Pull ext4 bugfixes from Ted Ts'o: "Revert a potential seek_data/hole regression which shows up when using ext4 to handle ext3 file systems, plus two minor bug fixes" * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: remove spurious KERN_INFO from ext4_warning call Revert "ext4: fix suboptimal seek_{data,hole} extents traversial" ext4: prevent online resize with backup superblock
This commit is contained in:
commit
3b421b80be
|
@ -5166,7 +5166,7 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
|
||||||
|
|
||||||
/* fallback to generic here if not in extents fmt */
|
/* fallback to generic here if not in extents fmt */
|
||||||
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
|
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
|
||||||
return __generic_block_fiemap(inode, fieinfo, start, len,
|
return generic_block_fiemap(inode, fieinfo, start, len,
|
||||||
ext4_get_block);
|
ext4_get_block);
|
||||||
|
|
||||||
if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS))
|
if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS))
|
||||||
|
|
200
fs/ext4/file.c
200
fs/ext4/file.c
|
@ -273,19 +273,24 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
|
||||||
* we determine this extent as a data or a hole according to whether the
|
* we determine this extent as a data or a hole according to whether the
|
||||||
* page cache has data or not.
|
* page cache has data or not.
|
||||||
*/
|
*/
|
||||||
static int ext4_find_unwritten_pgoff(struct inode *inode, int whence,
|
static int ext4_find_unwritten_pgoff(struct inode *inode,
|
||||||
loff_t endoff, loff_t *offset)
|
int whence,
|
||||||
|
struct ext4_map_blocks *map,
|
||||||
|
loff_t *offset)
|
||||||
{
|
{
|
||||||
struct pagevec pvec;
|
struct pagevec pvec;
|
||||||
|
unsigned int blkbits;
|
||||||
pgoff_t index;
|
pgoff_t index;
|
||||||
pgoff_t end;
|
pgoff_t end;
|
||||||
|
loff_t endoff;
|
||||||
loff_t startoff;
|
loff_t startoff;
|
||||||
loff_t lastoff;
|
loff_t lastoff;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
|
blkbits = inode->i_sb->s_blocksize_bits;
|
||||||
startoff = *offset;
|
startoff = *offset;
|
||||||
lastoff = startoff;
|
lastoff = startoff;
|
||||||
|
endoff = (loff_t)(map->m_lblk + map->m_len) << blkbits;
|
||||||
|
|
||||||
index = startoff >> PAGE_CACHE_SHIFT;
|
index = startoff >> PAGE_CACHE_SHIFT;
|
||||||
end = endoff >> PAGE_CACHE_SHIFT;
|
end = endoff >> PAGE_CACHE_SHIFT;
|
||||||
|
@ -403,144 +408,147 @@ out:
|
||||||
static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
|
static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
|
||||||
{
|
{
|
||||||
struct inode *inode = file->f_mapping->host;
|
struct inode *inode = file->f_mapping->host;
|
||||||
struct fiemap_extent_info fie;
|
struct ext4_map_blocks map;
|
||||||
struct fiemap_extent ext[2];
|
struct extent_status es;
|
||||||
loff_t next;
|
ext4_lblk_t start, last, end;
|
||||||
int i, ret = 0;
|
loff_t dataoff, isize;
|
||||||
|
int blkbits;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
if (offset >= inode->i_size) {
|
|
||||||
|
isize = i_size_read(inode);
|
||||||
|
if (offset >= isize) {
|
||||||
mutex_unlock(&inode->i_mutex);
|
mutex_unlock(&inode->i_mutex);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
fie.fi_flags = 0;
|
|
||||||
fie.fi_extents_max = 2;
|
|
||||||
fie.fi_extents_start = (struct fiemap_extent __user *) &ext;
|
|
||||||
while (1) {
|
|
||||||
mm_segment_t old_fs = get_fs();
|
|
||||||
|
|
||||||
fie.fi_extents_mapped = 0;
|
blkbits = inode->i_sb->s_blocksize_bits;
|
||||||
memset(ext, 0, sizeof(*ext) * fie.fi_extents_max);
|
start = offset >> blkbits;
|
||||||
|
last = start;
|
||||||
|
end = isize >> blkbits;
|
||||||
|
dataoff = offset;
|
||||||
|
|
||||||
set_fs(get_ds());
|
do {
|
||||||
ret = ext4_fiemap(inode, &fie, offset, maxsize - offset);
|
map.m_lblk = last;
|
||||||
set_fs(old_fs);
|
map.m_len = end - last + 1;
|
||||||
if (ret)
|
ret = ext4_map_blocks(NULL, inode, &map, 0);
|
||||||
break;
|
if (ret > 0 && !(map.m_flags & EXT4_MAP_UNWRITTEN)) {
|
||||||
|
if (last != start)
|
||||||
/* No extents found, EOF */
|
dataoff = (loff_t)last << blkbits;
|
||||||
if (!fie.fi_extents_mapped) {
|
|
||||||
ret = -ENXIO;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 0; i < fie.fi_extents_mapped; i++) {
|
|
||||||
next = (loff_t)(ext[i].fe_length + ext[i].fe_logical);
|
|
||||||
|
|
||||||
if (offset < (loff_t)ext[i].fe_logical)
|
|
||||||
offset = (loff_t)ext[i].fe_logical;
|
|
||||||
/*
|
/*
|
||||||
* If extent is not unwritten, then it contains valid
|
* If there is a delay extent at this offset,
|
||||||
* data, mapped or delayed.
|
* it will be as a data.
|
||||||
*/
|
*/
|
||||||
if (!(ext[i].fe_flags & FIEMAP_EXTENT_UNWRITTEN))
|
ext4_es_find_delayed_extent_range(inode, last, last, &es);
|
||||||
goto out;
|
if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) {
|
||||||
|
if (last != start)
|
||||||
|
dataoff = (loff_t)last << blkbits;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is a unwritten extent at this offset,
|
* If there is a unwritten extent at this offset,
|
||||||
* it will be as a data or a hole according to page
|
* it will be as a data or a hole according to page
|
||||||
* cache that has data or not.
|
* cache that has data or not.
|
||||||
*/
|
*/
|
||||||
if (ext4_find_unwritten_pgoff(inode, SEEK_DATA,
|
if (map.m_flags & EXT4_MAP_UNWRITTEN) {
|
||||||
next, &offset))
|
int unwritten;
|
||||||
goto out;
|
unwritten = ext4_find_unwritten_pgoff(inode, SEEK_DATA,
|
||||||
|
&map, &dataoff);
|
||||||
|
if (unwritten)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
last++;
|
||||||
|
dataoff = (loff_t)last << blkbits;
|
||||||
|
} while (last <= end);
|
||||||
|
|
||||||
if (ext[i].fe_flags & FIEMAP_EXTENT_LAST) {
|
|
||||||
ret = -ENXIO;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
offset = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (offset > inode->i_size)
|
|
||||||
offset = inode->i_size;
|
|
||||||
out:
|
|
||||||
mutex_unlock(&inode->i_mutex);
|
mutex_unlock(&inode->i_mutex);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return vfs_setpos(file, offset, maxsize);
|
if (dataoff > isize)
|
||||||
|
return -ENXIO;
|
||||||
|
|
||||||
|
return vfs_setpos(file, dataoff, maxsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ext4_seek_hole() retrieves the offset for SEEK_HOLE
|
* ext4_seek_hole() retrieves the offset for SEEK_HOLE.
|
||||||
*/
|
*/
|
||||||
static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
|
static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
|
||||||
{
|
{
|
||||||
struct inode *inode = file->f_mapping->host;
|
struct inode *inode = file->f_mapping->host;
|
||||||
struct fiemap_extent_info fie;
|
struct ext4_map_blocks map;
|
||||||
struct fiemap_extent ext[2];
|
struct extent_status es;
|
||||||
loff_t next;
|
ext4_lblk_t start, last, end;
|
||||||
int i, ret = 0;
|
loff_t holeoff, isize;
|
||||||
|
int blkbits;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
if (offset >= inode->i_size) {
|
|
||||||
|
isize = i_size_read(inode);
|
||||||
|
if (offset >= isize) {
|
||||||
mutex_unlock(&inode->i_mutex);
|
mutex_unlock(&inode->i_mutex);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
fie.fi_flags = 0;
|
blkbits = inode->i_sb->s_blocksize_bits;
|
||||||
fie.fi_extents_max = 2;
|
start = offset >> blkbits;
|
||||||
fie.fi_extents_start = (struct fiemap_extent __user *)&ext;
|
last = start;
|
||||||
while (1) {
|
end = isize >> blkbits;
|
||||||
mm_segment_t old_fs = get_fs();
|
holeoff = offset;
|
||||||
|
|
||||||
fie.fi_extents_mapped = 0;
|
do {
|
||||||
memset(ext, 0, sizeof(*ext));
|
map.m_lblk = last;
|
||||||
|
map.m_len = end - last + 1;
|
||||||
set_fs(get_ds());
|
ret = ext4_map_blocks(NULL, inode, &map, 0);
|
||||||
ret = ext4_fiemap(inode, &fie, offset, maxsize - offset);
|
if (ret > 0 && !(map.m_flags & EXT4_MAP_UNWRITTEN)) {
|
||||||
set_fs(old_fs);
|
last += ret;
|
||||||
if (ret)
|
holeoff = (loff_t)last << blkbits;
|
||||||
break;
|
|
||||||
|
|
||||||
/* No extents found */
|
|
||||||
if (!fie.fi_extents_mapped)
|
|
||||||
break;
|
|
||||||
|
|
||||||
for (i = 0; i < fie.fi_extents_mapped; i++) {
|
|
||||||
next = (loff_t)(ext[i].fe_logical + ext[i].fe_length);
|
|
||||||
/*
|
|
||||||
* If extent is not unwritten, then it contains valid
|
|
||||||
* data, mapped or delayed.
|
|
||||||
*/
|
|
||||||
if (!(ext[i].fe_flags & FIEMAP_EXTENT_UNWRITTEN)) {
|
|
||||||
if (offset < (loff_t)ext[i].fe_logical)
|
|
||||||
goto out;
|
|
||||||
offset = next;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there is a delay extent at this offset,
|
||||||
|
* we will skip this extent.
|
||||||
|
*/
|
||||||
|
ext4_es_find_delayed_extent_range(inode, last, last, &es);
|
||||||
|
if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) {
|
||||||
|
last = es.es_lblk + es.es_len;
|
||||||
|
holeoff = (loff_t)last << blkbits;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is a unwritten extent at this offset,
|
* If there is a unwritten extent at this offset,
|
||||||
* it will be as a data or a hole according to page
|
* it will be as a data or a hole according to page
|
||||||
* cache that has data or not.
|
* cache that has data or not.
|
||||||
*/
|
*/
|
||||||
if (ext4_find_unwritten_pgoff(inode, SEEK_HOLE,
|
if (map.m_flags & EXT4_MAP_UNWRITTEN) {
|
||||||
next, &offset))
|
int unwritten;
|
||||||
goto out;
|
unwritten = ext4_find_unwritten_pgoff(inode, SEEK_HOLE,
|
||||||
|
&map, &holeoff);
|
||||||
|
if (!unwritten) {
|
||||||
|
last += ret;
|
||||||
|
holeoff = (loff_t)last << blkbits;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* find a hole */
|
||||||
|
break;
|
||||||
|
} while (last <= end);
|
||||||
|
|
||||||
offset = next;
|
|
||||||
if (ext[i].fe_flags & FIEMAP_EXTENT_LAST)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (offset > inode->i_size)
|
|
||||||
offset = inode->i_size;
|
|
||||||
out:
|
|
||||||
mutex_unlock(&inode->i_mutex);
|
mutex_unlock(&inode->i_mutex);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return vfs_setpos(file, offset, maxsize);
|
if (holeoff > isize)
|
||||||
|
holeoff = isize;
|
||||||
|
|
||||||
|
return vfs_setpos(file, holeoff, maxsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -23,6 +23,18 @@ int ext4_resize_begin(struct super_block *sb)
|
||||||
if (!capable(CAP_SYS_RESOURCE))
|
if (!capable(CAP_SYS_RESOURCE))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are not using the primary superblock/GDT copy don't resize,
|
||||||
|
* because the user tools have no way of handling this. Probably a
|
||||||
|
* bad time to do it anyways.
|
||||||
|
*/
|
||||||
|
if (EXT4_SB(sb)->s_sbh->b_blocknr !=
|
||||||
|
le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
|
||||||
|
ext4_warning(sb, "won't resize using backup superblock at %llu",
|
||||||
|
(unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);
|
||||||
|
return -EPERM;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are not allowed to do online-resizing on a filesystem mounted
|
* We are not allowed to do online-resizing on a filesystem mounted
|
||||||
* with error, because it can destroy the filesystem easily.
|
* with error, because it can destroy the filesystem easily.
|
||||||
|
@ -758,18 +770,6 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
|
||||||
"EXT4-fs: ext4_add_new_gdb: adding group block %lu\n",
|
"EXT4-fs: ext4_add_new_gdb: adding group block %lu\n",
|
||||||
gdb_num);
|
gdb_num);
|
||||||
|
|
||||||
/*
|
|
||||||
* If we are not using the primary superblock/GDT copy don't resize,
|
|
||||||
* because the user tools have no way of handling this. Probably a
|
|
||||||
* bad time to do it anyways.
|
|
||||||
*/
|
|
||||||
if (EXT4_SB(sb)->s_sbh->b_blocknr !=
|
|
||||||
le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
|
|
||||||
ext4_warning(sb, "won't resize using backup superblock at %llu",
|
|
||||||
(unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdb_bh = sb_bread(sb, gdblock);
|
gdb_bh = sb_bread(sb, gdblock);
|
||||||
if (!gdb_bh)
|
if (!gdb_bh)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
|
@ -3482,7 +3482,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
|
if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
|
||||||
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
|
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
|
||||||
EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
|
EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
|
||||||
ext4_warning(sb, KERN_INFO "metadata_csum and uninit_bg are "
|
ext4_warning(sb, "metadata_csum and uninit_bg are "
|
||||||
"redundant flags; please run fsck.");
|
"redundant flags; please run fsck.");
|
||||||
|
|
||||||
/* Check for a known checksum algorithm */
|
/* Check for a known checksum algorithm */
|
||||||
|
|
Loading…
Reference in New Issue