Merge tag 'v4.4.40' into linux-linaro-lsk-v4.4
[firefly-linux-kernel-4.4.55.git] / fs / xfs / xfs_buf.c
index 3243cdf97f33f2998de6d8207d1128093a0ec587..eb1b8c8acfcbe25c8f11ee7b36f2d0ed5f9f0558 100644 (file)
@@ -604,6 +604,13 @@ found:
                }
        }
 
+       /*
+        * Clear b_error if this is a lookup from a caller that doesn't expect
+        * valid data to be found in the buffer.
+        */
+       if (!(flags & XBF_READ))
+               xfs_buf_ioerror(bp, 0);
+
        XFS_STATS_INC(target->bt_mount, xb_get);
        trace_xfs_buf_get(bp, flags, _RET_IP_);
        return bp;
@@ -1520,6 +1527,16 @@ xfs_wait_buftarg(
        LIST_HEAD(dispose);
        int loop = 0;
 
+       /*
+        * We need to flush the buffer workqueue to ensure that all IO
+        * completion processing is 100% done. Just waiting on buffer locks is
+        * not sufficient for async IO as the reference count held over IO is
+        * not released until after the buffer lock is dropped. Hence we need to
+        * ensure here that all reference counts have been dropped before we
+        * start walking the LRU list.
+        */
+       flush_workqueue(btp->bt_mount->m_buf_workqueue);
+
        /* loop until there is nothing left on the lru list. */
        while (list_lru_count(&btp->bt_lru)) {
                list_lru_walk(&btp->bt_lru, xfs_buftarg_wait_rele,