Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull UDF and ext3 fixes from Jan Kara: "One UDF data corruption fix and one ext3 fix where we didn't write everything to disk on fsync in one corner case." * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: udf: Fix data corruption for files in ICB ext3: Fix fdatasync() for files with only i_size changes
This commit is contained in:
commit
1b0a9069de
|
@ -3072,6 +3072,8 @@ static int ext3_do_update_inode(handle_t *handle,
|
|||
struct ext3_inode_info *ei = EXT3_I(inode);
|
||||
struct buffer_head *bh = iloc->bh;
|
||||
int err = 0, rc, block;
|
||||
int need_datasync = 0;
|
||||
__le32 disksize;
|
||||
uid_t i_uid;
|
||||
gid_t i_gid;
|
||||
|
||||
|
@ -3113,7 +3115,11 @@ again:
|
|||
raw_inode->i_gid_high = 0;
|
||||
}
|
||||
raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
|
||||
raw_inode->i_size = cpu_to_le32(ei->i_disksize);
|
||||
disksize = cpu_to_le32(ei->i_disksize);
|
||||
if (disksize != raw_inode->i_size) {
|
||||
need_datasync = 1;
|
||||
raw_inode->i_size = disksize;
|
||||
}
|
||||
raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
|
||||
raw_inode->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
|
||||
raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
|
||||
|
@ -3129,8 +3135,11 @@ again:
|
|||
if (!S_ISREG(inode->i_mode)) {
|
||||
raw_inode->i_dir_acl = cpu_to_le32(ei->i_dir_acl);
|
||||
} else {
|
||||
raw_inode->i_size_high =
|
||||
cpu_to_le32(ei->i_disksize >> 32);
|
||||
disksize = cpu_to_le32(ei->i_disksize >> 32);
|
||||
if (disksize != raw_inode->i_size_high) {
|
||||
raw_inode->i_size_high = disksize;
|
||||
need_datasync = 1;
|
||||
}
|
||||
if (ei->i_disksize > 0x7fffffffULL) {
|
||||
struct super_block *sb = inode->i_sb;
|
||||
if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
|
||||
|
@ -3183,6 +3192,8 @@ again:
|
|||
ext3_clear_inode_state(inode, EXT3_STATE_NEW);
|
||||
|
||||
atomic_set(&ei->i_sync_tid, handle->h_transaction->t_tid);
|
||||
if (need_datasync)
|
||||
atomic_set(&ei->i_datasync_tid, handle->h_transaction->t_tid);
|
||||
out_brelse:
|
||||
brelse (bh);
|
||||
ext3_std_error(inode->i_sb, err);
|
||||
|
|
|
@ -39,20 +39,24 @@
|
|||
#include "udf_i.h"
|
||||
#include "udf_sb.h"
|
||||
|
||||
static int udf_adinicb_readpage(struct file *file, struct page *page)
|
||||
static void __udf_adinicb_readpage(struct page *page)
|
||||
{
|
||||
struct inode *inode = page->mapping->host;
|
||||
char *kaddr;
|
||||
struct udf_inode_info *iinfo = UDF_I(inode);
|
||||
|
||||
BUG_ON(!PageLocked(page));
|
||||
|
||||
kaddr = kmap(page);
|
||||
memset(kaddr, 0, PAGE_CACHE_SIZE);
|
||||
memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size);
|
||||
memset(kaddr + inode->i_size, 0, PAGE_CACHE_SIZE - inode->i_size);
|
||||
flush_dcache_page(page);
|
||||
SetPageUptodate(page);
|
||||
kunmap(page);
|
||||
}
|
||||
|
||||
static int udf_adinicb_readpage(struct file *file, struct page *page)
|
||||
{
|
||||
BUG_ON(!PageLocked(page));
|
||||
__udf_adinicb_readpage(page);
|
||||
unlock_page(page);
|
||||
|
||||
return 0;
|
||||
|
@ -77,6 +81,25 @@ static int udf_adinicb_writepage(struct page *page,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int udf_adinicb_write_begin(struct file *file,
|
||||
struct address_space *mapping, loff_t pos,
|
||||
unsigned len, unsigned flags, struct page **pagep,
|
||||
void **fsdata)
|
||||
{
|
||||
struct page *page;
|
||||
|
||||
if (WARN_ON_ONCE(pos >= PAGE_CACHE_SIZE))
|
||||
return -EIO;
|
||||
page = grab_cache_page_write_begin(mapping, 0, flags);
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
*pagep = page;
|
||||
|
||||
if (!PageUptodate(page) && len != PAGE_CACHE_SIZE)
|
||||
__udf_adinicb_readpage(page);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int udf_adinicb_write_end(struct file *file,
|
||||
struct address_space *mapping,
|
||||
loff_t pos, unsigned len, unsigned copied,
|
||||
|
@ -98,8 +121,8 @@ static int udf_adinicb_write_end(struct file *file,
|
|||
const struct address_space_operations udf_adinicb_aops = {
|
||||
.readpage = udf_adinicb_readpage,
|
||||
.writepage = udf_adinicb_writepage,
|
||||
.write_begin = simple_write_begin,
|
||||
.write_end = udf_adinicb_write_end,
|
||||
.write_begin = udf_adinicb_write_begin,
|
||||
.write_end = udf_adinicb_write_end,
|
||||
};
|
||||
|
||||
static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
||||
|
|
Loading…
Reference in New Issue