File fix-GFP-flags-to-alloc-mem.patch of Package drbd.16493

commit 58dd62ef86e1af81552ccda1b891fa4d152c0dfb
Author: Philipp Reisner <philipp.reisner@linbit.com>
Date:   Wed Apr 17 13:07:44 2019 +0200

    drbd: Fix GFP flags in data path

    drbd_send_dblock() is indirectly in the data-path. Therefore it's
    allocations need to ensure to not cause other IO to start.

    Otherwise, this might happen under memory-pressure:

    Apr 17 01:28:31 linux1 kernel: INFO: task drbd_s_r0:14887 blocked for more than 120 seconds.
    Apr 17 01:28:31 linux1 kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    Apr 17 01:28:31 linux1 kernel: drbd_s_b2bi1_ap D ffff944f787fc100     0 14887      2 0x00000080
    Apr 17 01:28:31 linux1 kernel: Call Trace:
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb2f67c49>] schedule+0x29/0x70
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0315fe4>] _xfs_log_force_lsn+0x1b4/0x340 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28d67b0>] ? wake_up_state+0x20/0x20
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0303c2c>] ? __xfs_iunpin_wait+0x9c/0x150 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc03161a4>] xfs_log_force_lsn+0x34/0x70 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0306f89>] ? xfs_iunpin_wait+0x19/0x20 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0303c2c>] __xfs_iunpin_wait+0x9c/0x150 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28c2dc0>] ? wake_bit_function+0x40/0x40
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0306f89>] xfs_iunpin_wait+0x19/0x20 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc02fa7d3>] xfs_reclaim_inode+0x143/0x360 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc02fac57>] xfs_reclaim_inodes_ag+0x267/0x390 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb2856c22>] ? native_smp_send_reschedule+0x52/0x70
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28d1f9e>] ? resched_curr+0xae/0xc0
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28d2ea0>] ? check_preempt_curr+0x80/0xa0
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28d2ed9>] ? ttwu_do_wakeup+0x19/0xe0
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28d300f>] ? ttwu_do_activate+0x6f/0x80
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28d64f0>] ? try_to_wake_up+0x190/0x390
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28d6705>] ? wake_up_process+0x15/0x20
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc02fbe33>] xfs_reclaim_inodes_nr+0x33/0x40 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc030c445>] xfs_fs_free_cached_objects+0x15/0x20 [xfs]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb2a43f46>] prune_super+0xf6/0x190
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb29c9da5>] shrink_slab+0x175/0x340
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb2a37501>] ? vmpressure+0x61/0x90
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb29cd062>] do_try_to_free_pages+0x3c2/0x4e0
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb29cd27c>] try_to_free_pages+0xfc/0x180
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb2f5d1ef>] __alloc_pages_slowpath+0x457/0x724
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb2f6a31e>] ? _raw_spin_unlock_bh+0x1e/0x20
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb29c1105>] __alloc_pages_nodemask+0x405/0x420
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb2a0df68>] alloc_pages_current+0x98/0x110
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc052f0f4>] alloc_send_buffer+0x94/0x120 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0531d72>] __conn_prepare_command+0x62/0x80 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0531dd1>] conn_prepare_command+0x41/0x80 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0533b47>] drbd_send_dblock+0xd7/0x490 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc0507138>] process_one_request+0x158/0x320 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc050ccd2>] drbd_sender+0x3c2/0x420 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc05308b0>] ? do_retry+0x290/0x290 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc053094e>] drbd_thread_setup+0x9e/0x1d0 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffc05308b0>] ? do_retry+0x290/0x290 [drbd]
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28c1c31>] kthread+0xd1/0xe0
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28c1b60>] ? insert_kthread_work+0x40/0x40
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb2f74c37>] ret_from_fork_nospec_begin+0x21/0x21
    Apr 17 01:28:31 linux1 kernel: [<ffffffffb28c1b60>] ? insert_kthread_work+0x40/0x40

    I decided for __GFP_NOWARN, since DRBD can guarantee to make progress here as
    we get the previous page as soon as the tcp-stack managed to finish the
    send_page() operations on it.

diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c
index 16f047c0..3c11a7a8 100644
--- a/drbd/drbd_main.c
+++ b/drbd/drbd_main.c
@@ -966,7 +966,7 @@ static void new_or_recycle_send_buffer_page(struct drbd_send_buffer *sbuf)
 		if (count == 1)
 			goto have_page;

-		page = alloc_page(GFP_KERNEL);
+		page = alloc_page(GFP_NOIO | __GFP_NOWARN);
 		if (page) {
 			put_page(sbuf->page);
 			sbuf->page = page;
openSUSE Build Service is sponsored by