--- /dev/null
+From d641df819db8b80198fd85d9de91137e8a823b07 Mon Sep 17 00:00:00 2001
+From: "Yan, Zheng" <zyan@redhat.com>
+Date: Thu, 19 Jan 2017 11:21:29 +0800
+Subject: ceph: update readpages osd request according to size of pages
+
+From: Yan, Zheng <zyan@redhat.com>
+
+commit d641df819db8b80198fd85d9de91137e8a823b07 upstream.
+
+add_to_page_cache_lru() can fails, so the actual pages to read
+can be smaller than the initial size of osd request. We need to
+update osd request size in that case.
+
+Signed-off-by: Yan, Zheng <zyan@redhat.com>
+Reviewed-by: Jeff Layton <jlayton@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ceph/addr.c | 1 +
+ net/ceph/osd_client.c | 3 ++-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+--- a/fs/ceph/addr.c
++++ b/fs/ceph/addr.c
+@@ -363,6 +363,7 @@ static int start_read(struct inode *inod
+ nr_pages = i;
+ if (nr_pages > 0) {
+ len = nr_pages << PAGE_SHIFT;
++ osd_req_op_extent_update(req, 0, len);
+ break;
+ }
+ goto out_pages;
+--- a/net/ceph/osd_client.c
++++ b/net/ceph/osd_client.c
+@@ -672,7 +672,8 @@ void osd_req_op_extent_update(struct cep
+ BUG_ON(length > previous);
+
+ op->extent.length = length;
+- op->indata_len -= previous - length;
++ if (op->op == CEPH_OSD_OP_WRITE || op->op == CEPH_OSD_OP_WRITEFULL)
++ op->indata_len -= previous - length;
+ }
+ EXPORT_SYMBOL(osd_req_op_extent_update);
+
--- /dev/null
+From ae2f5e5ed04a17c1aa1f0a3714c725e12c21d2a9 Mon Sep 17 00:00:00 2001
+From: Ralf Baechle <ralf@linux-mips.org>
+Date: Thu, 15 Dec 2016 12:39:22 +0100
+Subject: MIPS: IP22: Fix build error due to binutils 2.25 uselessnes.
+
+From: Ralf Baechle <ralf@linux-mips.org>
+
+commit ae2f5e5ed04a17c1aa1f0a3714c725e12c21d2a9 upstream.
+
+Fix the following build error with binutils 2.25.
+
+ CC arch/mips/mm/sc-ip22.o
+{standard input}: Assembler messages:
+{standard input}:132: Error: number (0x9000000080000000) larger than 32 bits
+{standard input}:159: Error: number (0x9000000080000000) larger than 32 bits
+{standard input}:200: Error: number (0x9000000080000000) larger than 32 bits
+scripts/Makefile.build:293: recipe for target 'arch/mips/mm/sc-ip22.o' failed
+make[1]: *** [arch/mips/mm/sc-ip22.o] Error 1
+
+MIPS has used .set mips3 to temporarily switch the assembler to 64 bit
+mode in 64 bit kernels virtually forever. Binutils 2.25 broke this
+behavious partially by happily accepting 64 bit instructions in .set mips3
+mode but puking on 64 bit constants when generating 32 bit ELF. Binutils
+2.26 restored the old behaviour again.
+
+Fix build with binutils 2.25 by open coding the offending
+
+ dli $1, 0x9000000080000000
+
+as
+
+ li $1, 0x9000
+ dsll $1, $1, 48
+
+which is ugly be the only thing that will build on all binutils vintages.
+
+Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
+Cc: stable@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/mips/mm/sc-ip22.c | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+--- a/arch/mips/mm/sc-ip22.c
++++ b/arch/mips/mm/sc-ip22.c
+@@ -39,7 +39,18 @@ static inline void indy_sc_wipe(unsigned
+ " li $1, 0x80 # Go 64 bit \n"
+ " mtc0 $1, $12 \n"
+ " \n"
+- " dli $1, 0x9000000080000000 \n"
++ " # \n"
++ " # Open code a dli $1, 0x9000000080000000 \n"
++ " # \n"
++ " # Required because binutils 2.25 will happily accept \n"
++ " # 64 bit instructions in .set mips3 mode but puke on \n"
++ " # 64 bit constants when generating 32 bit ELF \n"
++ " # \n"
++ " lui $1,0x9000 \n"
++ " dsll $1,$1,0x10 \n"
++ " ori $1,$1,0x8000 \n"
++ " dsll $1,$1,0x10 \n"
++ " \n"
+ " or %0, $1 # first line to flush \n"
+ " or %1, $1 # last line to flush \n"
+ " .set at \n"
--- /dev/null
+From f9f1c8db1c37253805eaa32265e1e1af3ae7d0a4 Mon Sep 17 00:00:00 2001
+From: Ralf Baechle <ralf@linux-mips.org>
+Date: Thu, 15 Dec 2016 12:27:21 +0100
+Subject: MIPS: IP22: Reformat inline assembler code to modern standards.
+
+From: Ralf Baechle <ralf@linux-mips.org>
+
+commit f9f1c8db1c37253805eaa32265e1e1af3ae7d0a4 upstream.
+
+Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/mips/mm/sc-ip22.c | 43 +++++++++++++++++++++++--------------------
+ 1 file changed, 23 insertions(+), 20 deletions(-)
+
+--- a/arch/mips/mm/sc-ip22.c
++++ b/arch/mips/mm/sc-ip22.c
+@@ -31,26 +31,29 @@ static inline void indy_sc_wipe(unsigned
+ unsigned long tmp;
+
+ __asm__ __volatile__(
+- ".set\tpush\t\t\t# indy_sc_wipe\n\t"
+- ".set\tnoreorder\n\t"
+- ".set\tmips3\n\t"
+- ".set\tnoat\n\t"
+- "mfc0\t%2, $12\n\t"
+- "li\t$1, 0x80\t\t\t# Go 64 bit\n\t"
+- "mtc0\t$1, $12\n\t"
+-
+- "dli\t$1, 0x9000000080000000\n\t"
+- "or\t%0, $1\t\t\t# first line to flush\n\t"
+- "or\t%1, $1\t\t\t# last line to flush\n\t"
+- ".set\tat\n\t"
+-
+- "1:\tsw\t$0, 0(%0)\n\t"
+- "bne\t%0, %1, 1b\n\t"
+- " daddu\t%0, 32\n\t"
+-
+- "mtc0\t%2, $12\t\t\t# Back to 32 bit\n\t"
+- "nop; nop; nop; nop;\n\t"
+- ".set\tpop"
++ " .set push # indy_sc_wipe \n"
++ " .set noreorder \n"
++ " .set mips3 \n"
++ " .set noat \n"
++ " mfc0 %2, $12 \n"
++ " li $1, 0x80 # Go 64 bit \n"
++ " mtc0 $1, $12 \n"
++ " \n"
++ " dli $1, 0x9000000080000000 \n"
++ " or %0, $1 # first line to flush \n"
++ " or %1, $1 # last line to flush \n"
++ " .set at \n"
++ " \n"
++ "1: sw $0, 0(%0) \n"
++ " bne %0, %1, 1b \n"
++ " daddu %0, 32 \n"
++ " \n"
++ " mtc0 %2, $12 # Back to 32 bit \n"
++ " nop # pipeline hazard \n"
++ " nop \n"
++ " nop \n"
++ " nop \n"
++ " .set pop \n"
+ : "=r" (first), "=r" (last), "=&r" (tmp)
+ : "0" (first), "1" (last));
+ }
--- /dev/null
+From e5072053b09642b8ff417d47da05b84720aea3ee Mon Sep 17 00:00:00 2001
+From: Florian Westphal <fw@strlen.de>
+Date: Wed, 18 Jan 2017 02:01:22 +0100
+Subject: netfilter: conntrack: refine gc worker heuristics, redux
+
+From: Florian Westphal <fw@strlen.de>
+
+commit e5072053b09642b8ff417d47da05b84720aea3ee upstream.
+
+This further refines the changes made to conntrack gc_worker in
+commit e0df8cae6c16 ("netfilter: conntrack: refine gc worker heuristics").
+
+The main idea of that change was to reduce the scan interval when evictions
+take place.
+
+However, on the reporters' setup, there are 1-2 million conntrack entries
+in total and roughly 8k new (and closing) connections per second.
+
+In this case we'll always evict at least one entry per gc cycle and scan
+interval is always at 1 jiffy because of this test:
+
+ } else if (expired_count) {
+ gc_work->next_gc_run /= 2U;
+ next_run = msecs_to_jiffies(1);
+
+being true almost all the time.
+
+Given we scan ~10k entries per run its clearly wrong to reduce interval
+based on nonzero eviction count, it will only waste cpu cycles since a vast
+majorities of conntracks are not timed out.
+
+Thus only look at the ratio (scanned entries vs. evicted entries) to make
+a decision on whether to reduce or not.
+
+Because evictor is supposed to only kick in when system turns idle after
+a busy period, pick a high ratio -- this makes it 50%. We thus keep
+the idea of increasing scan rate when its likely that table contains many
+expired entries.
+
+In order to not let timed-out entries hang around for too long
+(important when using event logging, in which case we want to timely
+destroy events), we now scan the full table within at most
+GC_MAX_SCAN_JIFFIES (16 seconds) even in worst-case scenario where all
+timed-out entries sit in same slot.
+
+I tested this with a vm under synflood (with
+sysctl net.netfilter.nf_conntrack_tcp_timeout_syn_recv=3).
+
+While flood is ongoing, interval now stays at its max rate
+(GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV -> 125ms).
+
+With feedback from Nicolas Dichtel.
+
+Reported-by: Denys Fedoryshchenko <nuclearcat@nuclearcat.com>
+Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+Fixes: b87a2f9199ea82eaadc ("netfilter: conntrack: add gc worker to remove timed-out entries")
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Tested-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+Tested-by: Denys Fedoryshchenko <nuclearcat@nuclearcat.com>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/netfilter/nf_conntrack_core.c | 39 +++++++++++++++++++-------------------
+ 1 file changed, 20 insertions(+), 19 deletions(-)
+
+--- a/net/netfilter/nf_conntrack_core.c
++++ b/net/netfilter/nf_conntrack_core.c
+@@ -85,9 +85,11 @@ static __read_mostly DEFINE_SPINLOCK(nf_
+ static __read_mostly bool nf_conntrack_locks_all;
+
+ /* every gc cycle scans at most 1/GC_MAX_BUCKETS_DIV part of table */
+-#define GC_MAX_BUCKETS_DIV 64u
+-/* upper bound of scan intervals */
+-#define GC_INTERVAL_MAX (2 * HZ)
++#define GC_MAX_BUCKETS_DIV 128u
++/* upper bound of full table scan */
++#define GC_MAX_SCAN_JIFFIES (16u * HZ)
++/* desired ratio of entries found to be expired */
++#define GC_EVICT_RATIO 50u
+
+ static struct conntrack_gc_work conntrack_gc_work;
+
+@@ -936,6 +938,7 @@ static noinline int early_drop(struct ne
+
+ static void gc_worker(struct work_struct *work)
+ {
++ unsigned int min_interval = max(HZ / GC_MAX_BUCKETS_DIV, 1u);
+ unsigned int i, goal, buckets = 0, expired_count = 0;
+ struct conntrack_gc_work *gc_work;
+ unsigned int ratio, scanned = 0;
+@@ -994,27 +997,25 @@ static void gc_worker(struct work_struct
+ * 1. Minimize time until we notice a stale entry
+ * 2. Maximize scan intervals to not waste cycles
+ *
+- * Normally, expired_count will be 0, this increases the next_run time
+- * to priorize 2) above.
++ * Normally, expire ratio will be close to 0.
+ *
+- * As soon as a timed-out entry is found, move towards 1) and increase
+- * the scan frequency.
+- * In case we have lots of evictions next scan is done immediately.
++ * As soon as a sizeable fraction of the entries have expired
++ * increase scan frequency.
+ */
+ ratio = scanned ? expired_count * 100 / scanned : 0;
+- if (ratio >= 90) {
+- gc_work->next_gc_run = 0;
+- next_run = 0;
+- } else if (expired_count) {
+- gc_work->next_gc_run /= 2U;
+- next_run = msecs_to_jiffies(1);
++ if (ratio > GC_EVICT_RATIO) {
++ gc_work->next_gc_run = min_interval;
+ } else {
+- if (gc_work->next_gc_run < GC_INTERVAL_MAX)
+- gc_work->next_gc_run += msecs_to_jiffies(1);
++ unsigned int max = GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV;
+
+- next_run = gc_work->next_gc_run;
++ BUILD_BUG_ON((GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV) == 0);
++
++ gc_work->next_gc_run += min_interval;
++ if (gc_work->next_gc_run > max)
++ gc_work->next_gc_run = max;
+ }
+
++ next_run = gc_work->next_gc_run;
+ gc_work->last_bucket = i;
+ queue_delayed_work(system_long_wq, &gc_work->dwork, next_run);
+ }
+@@ -1022,7 +1023,7 @@ static void gc_worker(struct work_struct
+ static void conntrack_gc_work_init(struct conntrack_gc_work *gc_work)
+ {
+ INIT_DELAYED_WORK(&gc_work->dwork, gc_worker);
+- gc_work->next_gc_run = GC_INTERVAL_MAX;
++ gc_work->next_gc_run = HZ;
+ gc_work->exiting = false;
+ }
+
+@@ -1915,7 +1916,7 @@ int nf_conntrack_init_start(void)
+ nf_ct_untracked_status_or(IPS_CONFIRMED | IPS_UNTRACKED);
+
+ conntrack_gc_work_init(&conntrack_gc_work);
+- queue_delayed_work(system_long_wq, &conntrack_gc_work.dwork, GC_INTERVAL_MAX);
++ queue_delayed_work(system_long_wq, &conntrack_gc_work.dwork, HZ);
+
+ return 0;
+
--- /dev/null
+From 524b698db06b9b6da7192e749f637904e2f62d7b Mon Sep 17 00:00:00 2001
+From: Florian Westphal <fw@strlen.de>
+Date: Mon, 16 Jan 2017 18:24:56 +0100
+Subject: netfilter: conntrack: remove GC_MAX_EVICTS break
+
+From: Florian Westphal <fw@strlen.de>
+
+commit 524b698db06b9b6da7192e749f637904e2f62d7b upstream.
+
+Instead of breaking loop and instant resched, don't bother checking
+this in first place (the loop calls cond_resched for every bucket anyway).
+
+Suggested-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/netfilter/nf_conntrack_core.c | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+--- a/net/netfilter/nf_conntrack_core.c
++++ b/net/netfilter/nf_conntrack_core.c
+@@ -88,8 +88,6 @@ static __read_mostly bool nf_conntrack_l
+ #define GC_MAX_BUCKETS_DIV 64u
+ /* upper bound of scan intervals */
+ #define GC_INTERVAL_MAX (2 * HZ)
+-/* maximum conntracks to evict per gc run */
+-#define GC_MAX_EVICTS 256u
+
+ static struct conntrack_gc_work conntrack_gc_work;
+
+@@ -979,8 +977,7 @@ static void gc_worker(struct work_struct
+ */
+ rcu_read_unlock();
+ cond_resched_rcu_qs();
+- } while (++buckets < goal &&
+- expired_count < GC_MAX_EVICTS);
++ } while (++buckets < goal);
+
+ if (gc_work->exiting)
+ return;
+@@ -1005,7 +1002,7 @@ static void gc_worker(struct work_struct
+ * In case we have lots of evictions next scan is done immediately.
+ */
+ ratio = scanned ? expired_count * 100 / scanned : 0;
+- if (ratio >= 90 || expired_count == GC_MAX_EVICTS) {
++ if (ratio >= 90) {
+ gc_work->next_gc_run = 0;
+ next_run = 0;
+ } else if (expired_count) {
--- /dev/null
+From 8ea73db486cda442f0671f4bc9c03a76be398a28 Mon Sep 17 00:00:00 2001
+From: James Smart <jsmart2021@gmail.com>
+Date: Sun, 12 Feb 2017 13:52:25 -0800
+Subject: scsi: lpfc: Correct WQ creation for pagesize
+
+From: James Smart <jsmart2021@gmail.com>
+
+commit 8ea73db486cda442f0671f4bc9c03a76be398a28 upstream.
+
+Correct WQ creation for pagesize
+
+The driver was calculating the adapter command pagesize indicator from
+the system pagesize. However, the buffers the driver allocates are only
+one size (SLI4_PAGE_SIZE), so no calculation was necessary.
+
+Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
+Signed-off-by: James Smart <james.smart@broadcom.com>
+Reviewed-by: Hannes Reinecke <hare@suse.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Cc: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/lpfc/lpfc_hw4.h | 2 ++
+ drivers/scsi/lpfc/lpfc_sli.c | 9 +++++----
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+--- a/drivers/scsi/lpfc/lpfc_hw4.h
++++ b/drivers/scsi/lpfc/lpfc_hw4.h
+@@ -1185,6 +1185,7 @@ struct lpfc_mbx_wq_create {
+ #define lpfc_mbx_wq_create_page_size_SHIFT 0
+ #define lpfc_mbx_wq_create_page_size_MASK 0x000000FF
+ #define lpfc_mbx_wq_create_page_size_WORD word1
++#define LPFC_WQ_PAGE_SIZE_4096 0x1
+ #define lpfc_mbx_wq_create_wqe_size_SHIFT 8
+ #define lpfc_mbx_wq_create_wqe_size_MASK 0x0000000F
+ #define lpfc_mbx_wq_create_wqe_size_WORD word1
+@@ -1256,6 +1257,7 @@ struct rq_context {
+ #define lpfc_rq_context_page_size_SHIFT 0 /* Version 1 Only */
+ #define lpfc_rq_context_page_size_MASK 0x000000FF
+ #define lpfc_rq_context_page_size_WORD word0
++#define LPFC_RQ_PAGE_SIZE_4096 0x1
+ uint32_t reserved1;
+ uint32_t word2;
+ #define lpfc_rq_context_cq_id_SHIFT 16
+--- a/drivers/scsi/lpfc/lpfc_sli.c
++++ b/drivers/scsi/lpfc/lpfc_sli.c
+@@ -13678,7 +13678,7 @@ lpfc_wq_create(struct lpfc_hba *phba, st
+ LPFC_WQ_WQE_SIZE_128);
+ bf_set(lpfc_mbx_wq_create_page_size,
+ &wq_create->u.request_1,
+- (PAGE_SIZE/SLI4_PAGE_SIZE));
++ LPFC_WQ_PAGE_SIZE_4096);
+ page = wq_create->u.request_1.page;
+ break;
+ }
+@@ -13704,8 +13704,9 @@ lpfc_wq_create(struct lpfc_hba *phba, st
+ LPFC_WQ_WQE_SIZE_128);
+ break;
+ }
+- bf_set(lpfc_mbx_wq_create_page_size, &wq_create->u.request_1,
+- (PAGE_SIZE/SLI4_PAGE_SIZE));
++ bf_set(lpfc_mbx_wq_create_page_size,
++ &wq_create->u.request_1,
++ LPFC_WQ_PAGE_SIZE_4096);
+ page = wq_create->u.request_1.page;
+ break;
+ default:
+@@ -13891,7 +13892,7 @@ lpfc_rq_create(struct lpfc_hba *phba, st
+ LPFC_RQE_SIZE_8);
+ bf_set(lpfc_rq_context_page_size,
+ &rq_create->u.request.context,
+- (PAGE_SIZE/SLI4_PAGE_SIZE));
++ LPFC_RQ_PAGE_SIZE_4096);
+ } else {
+ switch (hrq->entry_count) {
+ default:
powerpc-xmon-fix-data-breakpoint.patch
powerpc-mm-add-mmu_ftr_kernel_ro-to-possible-feature-mask.patch
powerpc-mm-hash-always-clear-uprt-and-host-radix-bits-when-setting-up-cpu.patch
+mips-ip22-reformat-inline-assembler-code-to-modern-standards.patch
+mips-ip22-fix-build-error-due-to-binutils-2.25-uselessnes.patch
+scsi-lpfc-correct-wq-creation-for-pagesize.patch
+ceph-update-readpages-osd-request-according-to-size-of-pages.patch
+netfilter-conntrack-remove-gc_max_evicts-break.patch
+netfilter-conntrack-refine-gc-worker-heuristics-redux.patch