Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5134246pxj; Wed, 9 Jun 2021 09:55:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwe4yn55ukBIZYYXRbYge8x1WyoGanQsZ/UNUWjz4fTAvLFee2l0B/cr8naBiYIvEBLZfak X-Received: by 2002:a05:6402:8d4:: with SMTP id d20mr369878edz.117.1623257707883; Wed, 09 Jun 2021 09:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623257707; cv=none; d=google.com; s=arc-20160816; b=0crOoRSNP9dqRUeUNNqHpCXlYa6l9RmRMepKprxtgFy76PtLrAXkjc8Z1Mc+Z4kxpJ Se5+cceeMrxUvZf7kBszma+czlpFmNl3DuMgqzTJ7kbplZYfgxqwbBi1kYQwlub6YaUe I5/joeDC/AnREM38oFYsLdpVvbP2lqSMJa/Tk2Ujtp62JIq3kRfa+XsCLiadRdIJX39q gcYcEoWIqgWvxGDSRGnoGNXfMwhNN+7MVdZeeXnWxIaSTlTsG2/GT5LmqmaEh/z7sgdf N44FL93OX+h51x++ah0kpWx21OHRZV7kQ1ktUnKOXKQ22UsWQ5L/cfCQX4B1aGIW7f6k VWpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XHzrcLeP1URuGcDcVxjPjZJfQ6zGXzyOoJIlmU7mig8=; b=nEfJ9edEm4aQiICRXgDSB7bRAR7LT+nrF0KzqR7vGu5aNb+2yefs4MRFzQfp1jvyeO A5lu3/17JXzGCx66EYj+Dz1Xd8jjJisX67kAW5R8Ig5ydQPGbbx9H0VY4icdnSWn22/q 7ReCAVxn5WXfef/tWQqLv8CLqsrXZGhixCMN35u6n+jDRLv4E48xWpO4VmQmmTQ+BM89 FAZsCPLYeMZauPK4H9jtTf2rYC0WP6qJc0fNJ6vETaYdgLNPQP/Ub0bfnK1Bk/iGJYeu i8pKaNLOkmP/v3/In/z1qlhbg8Z3KRbbxIYAC/mjRiiEDn1HVxT8n8hMqV+eDjATPILo p56Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=TE7I+A4F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f23si154505edv.591.2021.06.09.09.54.43; Wed, 09 Jun 2021 09:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=TE7I+A4F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235323AbhFHXJs (ORCPT + 99 others); Tue, 8 Jun 2021 19:09:48 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:9764 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235225AbhFHXJr (ORCPT ); Tue, 8 Jun 2021 19:09:47 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 158MwCGD030313 for ; Tue, 8 Jun 2021 16:07:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=XHzrcLeP1URuGcDcVxjPjZJfQ6zGXzyOoJIlmU7mig8=; b=TE7I+A4FsBIMRNuZ+lPM2MpLGWL+AiIqiOZ0tR9V7U/y5MY9VN1C3SPMNZ3UCd5ccnAT BEFREIW0Rd7wfSLNfWg+cZFY/RjgqgpJheO00NGqbPNddhy660NmJw25QWvXyKJFH4hy G0RAEImE4SYz+Ms6okklIA15/JlAhNfguYE= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 391mx0tdyf-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 08 Jun 2021 16:07:54 -0700 Received: from intmgw001.05.prn6.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 8 Jun 2021 16:07:50 -0700 Received: by devvm3388.prn0.facebook.com (Postfix, from userid 111017) id 3FFF082542CD; Tue, 8 Jun 2021 16:02:28 -0700 (PDT) From: Roman Gushchin To: Andrew Morton , Tejun Heo CC: , , , Alexander Viro , Jan Kara , Dennis Zhou , Dave Chinner , , Roman Gushchin Subject: [PATCH v9 4/8] writeback, cgroup: switch to rcu_work API in inode_switch_wbs() Date: Tue, 8 Jun 2021 16:02:21 -0700 Message-ID: <20210608230225.2078447-5-guro@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210608230225.2078447-1-guro@fb.com> References: <20210608230225.2078447-1-guro@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: -yOFKNPHpN6e9ZqMOne7L2cxZqjndrg6 X-Proofpoint-ORIG-GUID: -yOFKNPHpN6e9ZqMOne7L2cxZqjndrg6 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-08_17:2021-06-04,2021-06-08 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 bulkscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106080145 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Inode's wb switching requires two steps divided by an RCU grace period. It's currently implemented as an RCU callback inode_switch_wbs_rcu_fn(), which schedules inode_switch_wbs_work_fn() as a work. Switching to the rcu_work API allows to do the same in a cleaner and slightly shorter form. Signed-off-by: Roman Gushchin Reviewed-by: Jan Kara Acked-by: Tejun Heo Acked-by: Dennis Zhou --- fs/fs-writeback.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 4413e005c28c..8265dccd8da5 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -335,8 +335,7 @@ struct inode_switch_wbs_context { struct inode *inode; struct bdi_writeback *new_wb; =20 - struct rcu_head rcu_head; - struct work_struct work; + struct rcu_work work; }; =20 static void bdi_down_write_wb_switch_rwsem(struct backing_dev_info *bdi) @@ -352,7 +351,7 @@ static void bdi_up_write_wb_switch_rwsem(struct backi= ng_dev_info *bdi) static void inode_switch_wbs_work_fn(struct work_struct *work) { struct inode_switch_wbs_context *isw =3D - container_of(work, struct inode_switch_wbs_context, work); + container_of(to_rcu_work(work), struct inode_switch_wbs_context, work)= ; struct inode *inode =3D isw->inode; struct backing_dev_info *bdi =3D inode_to_bdi(inode); struct address_space *mapping =3D inode->i_mapping; @@ -469,16 +468,6 @@ static void inode_switch_wbs_work_fn(struct work_str= uct *work) atomic_dec(&isw_nr_in_flight); } =20 -static void inode_switch_wbs_rcu_fn(struct rcu_head *rcu_head) -{ - struct inode_switch_wbs_context *isw =3D container_of(rcu_head, - struct inode_switch_wbs_context, rcu_head); - - /* needs to grab bh-unsafe locks, bounce to work item */ - INIT_WORK(&isw->work, inode_switch_wbs_work_fn); - queue_work(isw_wq, &isw->work); -} - /** * inode_switch_wbs - change the wb association of an inode * @inode: target inode @@ -536,7 +525,8 @@ static void inode_switch_wbs(struct inode *inode, int= new_wb_id) * lock so that stat transfer can synchronize against them. * Let's continue after I_WB_SWITCH is guaranteed to be visible. */ - call_rcu(&isw->rcu_head, inode_switch_wbs_rcu_fn); + INIT_RCU_WORK(&isw->work, inode_switch_wbs_work_fn); + queue_rcu_work(isw_wq, &isw->work); return; =20 out_free: --=20 2.31.1