|
@@ -2495,6 +2495,20 @@ static int ext4_nonda_switch(struct super_block *sb)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+/* We always reserve for an inode update; the superblock could be there too */
|
|
|
+static int ext4_da_write_credits(struct inode *inode, loff_t pos, unsigned len)
|
|
|
+{
|
|
|
+ if (likely(EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
|
|
|
+ EXT4_FEATURE_RO_COMPAT_LARGE_FILE)))
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ if (pos + len <= 0x7fffffffULL)
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ /* We might need to update the superblock to set LARGE_FILE */
|
|
|
+ return 2;
|
|
|
+}
|
|
|
+
|
|
|
static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
|
|
|
loff_t pos, unsigned len, unsigned flags,
|
|
|
struct page **pagep, void **fsdata)
|
|
@@ -2545,7 +2559,8 @@ retry_grab:
|
|
|
* of file which has an already mapped buffer.
|
|
|
*/
|
|
|
retry_journal:
|
|
|
- handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, 1);
|
|
|
+ handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
|
|
|
+ ext4_da_write_credits(inode, pos, len));
|
|
|
if (IS_ERR(handle)) {
|
|
|
page_cache_release(page);
|
|
|
return PTR_ERR(handle);
|