--- /dev/null
+From 261cb20cb2f0737a247aaf08dff7eb065e3e5b66 Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack@suse.cz>
+Date: Thu, 20 Dec 2012 00:07:18 -0500
+Subject: ext4: check dioread_nolock on remount
+
+From: Jan Kara <jack@suse.cz>
+
+commit 261cb20cb2f0737a247aaf08dff7eb065e3e5b66 upstream.
+
+Currently we allow enabling dioread_nolock mount option on remount for
+filesystems where blocksize < PAGE_CACHE_SIZE. This isn't really
+supported so fix the bug by moving the check for blocksize !=
+PAGE_CACHE_SIZE into parse_options(). Change the original PAGE_SIZE to
+PAGE_CACHE_SIZE along the way because that's what we are really
+interested in.
+
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
+Reviewed-by: Eric Sandeen <sandeen@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext4/super.c | 22 +++++++++++-----------
+ 1 file changed, 11 insertions(+), 11 deletions(-)
+
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -1599,9 +1599,7 @@ static int parse_options(char *options,
+ unsigned int *journal_ioprio,
+ int is_remount)
+ {
+-#ifdef CONFIG_QUOTA
+ struct ext4_sb_info *sbi = EXT4_SB(sb);
+-#endif
+ char *p;
+ substring_t args[MAX_OPT_ARGS];
+ int token;
+@@ -1650,6 +1648,16 @@ static int parse_options(char *options,
+ }
+ }
+ #endif
++ if (test_opt(sb, DIOREAD_NOLOCK)) {
++ int blocksize =
++ BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
++
++ if (blocksize < PAGE_CACHE_SIZE) {
++ ext4_msg(sb, KERN_ERR, "can't mount with "
++ "dioread_nolock if block size != PAGE_SIZE");
++ return 0;
++ }
++ }
+ return 1;
+ }
+
+@@ -3226,15 +3234,6 @@ static int ext4_fill_super(struct super_
+ clear_opt(sb, DELALLOC);
+ }
+
+- blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
+- if (test_opt(sb, DIOREAD_NOLOCK)) {
+- if (blocksize < PAGE_SIZE) {
+- ext4_msg(sb, KERN_ERR, "can't mount with "
+- "dioread_nolock if block size != PAGE_SIZE");
+- goto failed_mount;
+- }
+- }
+-
+ sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
+ (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
+
+@@ -3276,6 +3275,7 @@ static int ext4_fill_super(struct super_
+ if (!ext4_feature_set_ok(sb, (sb->s_flags & MS_RDONLY)))
+ goto failed_mount;
+
++ blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
+ if (blocksize < EXT4_MIN_BLOCK_SIZE ||
+ blocksize > EXT4_MAX_BLOCK_SIZE) {
+ ext4_msg(sb, KERN_ERR,
--- /dev/null
+From d096ad0f79a782935d2e06ae8fb235e8c5397775 Mon Sep 17 00:00:00 2001
+From: Michael Tokarev <mjt@tls.msk.ru>
+Date: Tue, 25 Dec 2012 14:08:16 -0500
+Subject: ext4: do not try to write superblock on ro remount w/o journal
+
+From: Michael Tokarev <mjt@tls.msk.ru>
+
+commit d096ad0f79a782935d2e06ae8fb235e8c5397775 upstream.
+
+When a journal-less ext4 filesystem is mounted on a read-only block
+device (blockdev --setro will do), each remount (for other, unrelated,
+flags, like suid=>nosuid etc) results in a series of scary messages
+from kernel telling about I/O errors on the device.
+
+This is becauese of the following code ext4_remount():
+
+ if (sbi->s_journal == NULL)
+ ext4_commit_super(sb, 1);
+
+at the end of remount procedure, which forces writing (flushing) of
+a superblock regardless whenever it is dirty or not, if the filesystem
+is readonly or not, and whenever the device itself is readonly or not.
+
+We only need call ext4_commit_super when the file system had been
+previously mounted read/write.
+
+Thanks to Eric Sandeen for help in diagnosing this issue.
+
+Signed-off-By: Michael Tokarev <mjt@tls.msk.ru>
+Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext4/super.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -4506,7 +4506,7 @@ static int ext4_remount(struct super_blo
+ }
+
+ ext4_setup_system_zone(sb);
+- if (sbi->s_journal == NULL)
++ if (sbi->s_journal == NULL && !(old_sb_flags & MS_RDONLY))
+ ext4_commit_super(sb, 1);
+
+ #ifdef CONFIG_QUOTA
--- /dev/null
+From c36575e663e302dbaa4d16b9c72d2c9a913a9aef Mon Sep 17 00:00:00 2001
+From: Forrest Liu <forrestl@synology.com>
+Date: Mon, 17 Dec 2012 09:55:39 -0500
+Subject: ext4: fix extent tree corruption caused by hole punch
+
+From: Forrest Liu <forrestl@synology.com>
+
+commit c36575e663e302dbaa4d16b9c72d2c9a913a9aef upstream.
+
+When depth of extent tree is greater than 1, logical start value of
+interior node is not correctly updated in ext4_ext_rm_idx.
+
+Signed-off-by: Forrest Liu <forrestl@synology.com>
+Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
+Reviewed-by: Ashish Sangwan <ashishsangwan2@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext4/extents.c | 22 ++++++++++++++++++----
+ 1 file changed, 18 insertions(+), 4 deletions(-)
+
+--- a/fs/ext4/extents.c
++++ b/fs/ext4/extents.c
+@@ -2110,13 +2110,14 @@ ext4_ext_in_cache(struct inode *inode, e
+ * removes index from the index block.
+ */
+ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
+- struct ext4_ext_path *path)
++ struct ext4_ext_path *path, int depth)
+ {
+ int err;
+ ext4_fsblk_t leaf;
+
+ /* free index block */
+- path--;
++ depth--;
++ path = path + depth;
+ leaf = ext4_idx_pblock(path->p_idx);
+ if (unlikely(path->p_hdr->eh_entries == 0)) {
+ EXT4_ERROR_INODE(inode, "path->p_hdr->eh_entries == 0");
+@@ -2141,6 +2142,19 @@ static int ext4_ext_rm_idx(handle_t *han
+
+ ext4_free_blocks(handle, inode, NULL, leaf, 1,
+ EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET);
++
++ while (--depth >= 0) {
++ if (path->p_idx != EXT_FIRST_INDEX(path->p_hdr))
++ break;
++ path--;
++ err = ext4_ext_get_access(handle, inode, path);
++ if (err)
++ break;
++ path->p_idx->ei_block = (path+1)->p_idx->ei_block;
++ err = ext4_ext_dirty(handle, inode, path);
++ if (err)
++ break;
++ }
+ return err;
+ }
+
+@@ -2474,7 +2488,7 @@ ext4_ext_rm_leaf(handle_t *handle, struc
+ /* if this leaf is free, then we should
+ * remove it from index block above */
+ if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL)
+- err = ext4_ext_rm_idx(handle, inode, path + depth);
++ err = ext4_ext_rm_idx(handle, inode, path, depth);
+
+ out:
+ return err;
+@@ -2675,7 +2689,7 @@ cont:
+ /* index is empty, remove it;
+ * handle must be already prepared by the
+ * truncatei_leaf() */
+- err = ext4_ext_rm_idx(handle, inode, path + i);
++ err = ext4_ext_rm_idx(handle, inode, path, i);
+ }
+ /* root level has p_bh == NULL, brelse() eats this */
+ brelse(path[i].p_bh);
--- /dev/null
+From 721e3eba21e43532e438652dd8f1fcdfce3187e7 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso@mit.edu>
+Date: Thu, 27 Dec 2012 01:42:48 -0500
+Subject: ext4: lock i_mutex when truncating orphan inodes
+
+From: Theodore Ts'o <tytso@mit.edu>
+
+commit 721e3eba21e43532e438652dd8f1fcdfce3187e7 upstream.
+
+Commit c278531d39 added a warning when ext4_flush_unwritten_io() is
+called without i_mutex being taken. It had previously not been taken
+during orphan cleanup since races weren't possible at that point in
+the mount process, but as a result of this c278531d39, we will now see
+a kernel WARN_ON in this case. Take the i_mutex in
+ext4_orphan_cleanup() to suppress this warning.
+
+Reported-by: Alexander Beregalov <a.beregalov@gmail.com>
+Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
+Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext4/super.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -2120,7 +2120,9 @@ static void ext4_orphan_cleanup(struct s
+ __func__, inode->i_ino, inode->i_size);
+ jbd_debug(2, "truncating inode %lu to %lld bytes\n",
+ inode->i_ino, inode->i_size);
++ mutex_lock(&inode->i_mutex);
+ ext4_truncate(inode);
++ mutex_unlock(&inode->i_mutex);
+ nr_truncates++;
+ } else {
+ ext4_msg(sb, KERN_DEBUG,
--- /dev/null
+From d7961c7fa4d2e3c3f12be67e21ba8799b5a7238a Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack@suse.cz>
+Date: Fri, 21 Dec 2012 00:15:51 -0500
+Subject: jbd2: fix assertion failure in jbd2_journal_flush()
+
+From: Jan Kara <jack@suse.cz>
+
+commit d7961c7fa4d2e3c3f12be67e21ba8799b5a7238a upstream.
+
+The following race is possible between start_this_handle() and someone
+calling jbd2_journal_flush().
+
+Process A Process B
+start_this_handle().
+ if (journal->j_barrier_count) # false
+ if (!journal->j_running_transaction) { #true
+ read_unlock(&journal->j_state_lock);
+ jbd2_journal_lock_updates()
+ jbd2_journal_flush()
+ write_lock(&journal->j_state_lock);
+ if (journal->j_running_transaction) {
+ # false
+ ... wait for committing trans ...
+ write_unlock(&journal->j_state_lock);
+ ...
+ write_lock(&journal->j_state_lock);
+ if (!journal->j_running_transaction) { # true
+ jbd2_get_transaction(journal, new_transaction);
+ write_unlock(&journal->j_state_lock);
+ goto repeat; # eventually blocks on j_barrier_count > 0
+ ...
+ J_ASSERT(!journal->j_running_transaction);
+ # fails
+
+We fix the race by rechecking j_barrier_count after reacquiring j_state_lock
+in exclusive mode.
+
+Reported-by: yjwsignal@empal.com
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/jbd2/transaction.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/fs/jbd2/transaction.c
++++ b/fs/jbd2/transaction.c
+@@ -209,7 +209,8 @@ repeat:
+ if (!new_transaction)
+ goto alloc_transaction;
+ write_lock(&journal->j_state_lock);
+- if (!journal->j_running_transaction) {
++ if (!journal->j_running_transaction &&
++ !journal->j_barrier_count) {
+ jbd2_get_transaction(journal, new_transaction);
+ new_transaction = NULL;
+ }
hwmon-lm73-detect-and-report-i2c-bus-errors.patch
video-mxsfb-fix-crash-when-unblanking-the-display.patch
samsung-laptop-add-quirk-for-broken-acpi_video-backlight-on-n250p.patch
+ext4-fix-extent-tree-corruption-caused-by-hole-punch.patch
+ext4-check-dioread_nolock-on-remount.patch
+jbd2-fix-assertion-failure-in-jbd2_journal_flush.patch
+ext4-do-not-try-to-write-superblock-on-ro-remount-w-o-journal.patch
+ext4-lock-i_mutex-when-truncating-orphan-inodes.patch