From patchwork Sat May 30 09:12:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 11581721 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D36BF139A for ; Mon, 1 Jun 2020 08:25:54 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 921CF2063A for ; Mon, 1 Jun 2020 08:25:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="b9p4Bnok" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 921CF2063A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=zoho.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590999953; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BV/W3/WNwIoKlIlxCXsiOny6q6Pf2yI9GdUNbl1zCEo=; b=b9p4BnokNHthMEQSM3Ke0YEuxL/oACsr1L+oxiqyo4M219Fz9PCUHcPdsWMixEhucjHzbQ V9SkDBXVSvEyf+wZNz79dkdFyXebg0U6StcJ9zmnV/8rQvIgfgx9ZxMiUyg8iBTLUv7u1w D+ENvfAmoKoWXrgS5j5B12WzvwsM/qQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-hfELEuTeNcSWeo6n-CDdGQ-1; Mon, 01 Jun 2020 04:25:48 -0400 X-MC-Unique: hfELEuTeNcSWeo6n-CDdGQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD971107ACCA; Mon, 1 Jun 2020 08:25:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7008CD01F6; Mon, 1 Jun 2020 08:25:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6454B7F21D; Mon, 1 Jun 2020 08:25:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04U9DNMS002925 for ; Sat, 30 May 2020 05:13:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id A28C7202696B; Sat, 30 May 2020 09:13:23 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9306F2026DFD for ; Sat, 30 May 2020 09:13:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96A95805BC5 for ; Sat, 30 May 2020 09:13:21 +0000 (UTC) Received: from sender4-pp-o92.zoho.com (sender4-pp-o92.zoho.com [136.143.188.92]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269--xNN9rPhNzaybMyHfXw43Q-1; Sat, 30 May 2020 05:13:18 -0400 X-MC-Unique: -xNN9rPhNzaybMyHfXw43Q-1 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id; b=InSRFFHZIqX5BX2gNEKPbW6KoxBQbmgcqpQKevNkSbLk3Rp/XFOi4xHgQMXIFTpOVJSsXvYqF+w7 cCkb6XYMW+vTeqt0AdF5HHBhOC4uJZsDaLTpct4MtdqpwwAr0+LN Received: from YEHS1XPF1D05WL.lenovo.com (111.197.250.66 [111.197.250.66]) by mx.zohomail.com with SMTPS id 1590829993582376.40498152393263; Sat, 30 May 2020 02:13:13 -0700 (PDT) From: Huaisheng Ye To: mpatocka@redhat.com, snitzer@redhat.com, agk@redhat.com Date: Sat, 30 May 2020 17:12:50 +0800 Message-Id: <20200530091250.58420-1-yehs2007@zoho.com> X-ZohoMailClient: External X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 01 Jun 2020 04:25:39 -0400 Cc: prarit@redhat.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, tyu1@lenovo.com, Huaisheng Ye Subject: [dm-devel] [PATCH] dm writecache: reinitialize lru in writeback instead of endio X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Huaisheng Ye When wc_entry has been removed from wbl->list in writeback, it will be not used again except waiting to be set free in writecache_free_entry. That is a little of annoying, it has to reinitialize lru of wc_entry in endio before calling writecache_free_entry. Using list_del_init instead of list_del in writeback for simpler code. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 7bbc21b..66f3a3b 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1519,7 +1519,6 @@ static void __writecache_endio_pmem(struct dm_writecache *wc, struct list_head * e = wb->wc_list[i]; BUG_ON(!e->write_in_progress); e->write_in_progress = false; - INIT_LIST_HEAD(&e->lru); if (!writecache_has_error(wc)) writecache_free_entry(wc, e); BUG_ON(!wc->writeback_size); @@ -1555,7 +1554,6 @@ static void __writecache_endio_ssd(struct dm_writecache *wc, struct list_head *l do { BUG_ON(!e->write_in_progress); e->write_in_progress = false; - INIT_LIST_HEAD(&e->lru); if (!writecache_has_error(wc)) writecache_free_entry(wc, e); @@ -1654,7 +1652,7 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba while (wbl->size) { wbl->size--; e = container_of(wbl->list.prev, struct wc_entry, lru); - list_del(&e->lru); + list_del_init(&e->lru); max_pages = e->wc_list_contiguous; @@ -1685,7 +1683,7 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba if (!wc_add_block(wb, f, GFP_NOWAIT | __GFP_NOWARN)) break; wbl->size--; - list_del(&f->lru); + list_del_init(&f->lru); wb->wc_list[wb->wc_list_n++] = f; e = f; } @@ -1712,7 +1710,7 @@ static void __writecache_writeback_ssd(struct dm_writecache *wc, struct writebac wbl->size--; e = container_of(wbl->list.prev, struct wc_entry, lru); - list_del(&e->lru); + list_del_init(&e->lru); n_sectors = e->wc_list_contiguous << (wc->block_size_bits - SECTOR_SHIFT); @@ -1732,7 +1730,7 @@ static void __writecache_writeback_ssd(struct dm_writecache *wc, struct writebac wbl->size--; f = container_of(wbl->list.prev, struct wc_entry, lru); BUG_ON(f != e + 1); - list_del(&f->lru); + list_del_init(&f->lru); e = f; }