Commit a94c7fde authored by Daeho Jeong's avatar Daeho Jeong Committed by Jaegeuk Kim

f2fs: support SEEK_DATA and SEEK_HOLE for compression files

Fix to support SEEK_DATA and SEEK_HOLE for compression files
Signed-off-by: default avatarDaeho Jeong <daehojeong@google.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent e39602da
...@@ -394,9 +394,20 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -394,9 +394,20 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
return f2fs_do_sync_file(file, start, end, datasync, false); return f2fs_do_sync_file(file, start, end, datasync, false);
} }
static bool __found_offset(struct address_space *mapping, block_t blkaddr, static bool __found_offset(struct address_space *mapping,
pgoff_t index, int whence) struct dnode_of_data *dn, pgoff_t index, int whence)
{ {
block_t blkaddr = f2fs_data_blkaddr(dn);
struct inode *inode = mapping->host;
bool compressed_cluster = false;
if (f2fs_compressed_file(inode)) {
block_t first_blkaddr = data_blkaddr(dn->inode, dn->node_page,
ALIGN_DOWN(dn->ofs_in_node, F2FS_I(inode)->i_cluster_size));
compressed_cluster = first_blkaddr == COMPRESS_ADDR;
}
switch (whence) { switch (whence) {
case SEEK_DATA: case SEEK_DATA:
if (__is_valid_data_blkaddr(blkaddr)) if (__is_valid_data_blkaddr(blkaddr))
...@@ -404,8 +415,12 @@ static bool __found_offset(struct address_space *mapping, block_t blkaddr, ...@@ -404,8 +415,12 @@ static bool __found_offset(struct address_space *mapping, block_t blkaddr,
if (blkaddr == NEW_ADDR && if (blkaddr == NEW_ADDR &&
xa_get_mark(&mapping->i_pages, index, PAGECACHE_TAG_DIRTY)) xa_get_mark(&mapping->i_pages, index, PAGECACHE_TAG_DIRTY))
return true; return true;
if (compressed_cluster)
return true;
break; break;
case SEEK_HOLE: case SEEK_HOLE:
if (compressed_cluster)
return false;
if (blkaddr == NULL_ADDR) if (blkaddr == NULL_ADDR)
return true; return true;
break; break;
...@@ -474,7 +489,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence) ...@@ -474,7 +489,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
goto fail; goto fail;
} }
if (__found_offset(file->f_mapping, blkaddr, if (__found_offset(file->f_mapping, &dn,
pgofs, whence)) { pgofs, whence)) {
f2fs_put_dnode(&dn); f2fs_put_dnode(&dn);
goto found; goto found;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment