Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1236700ybl; Fri, 13 Dec 2019 11:50:50 -0800 (PST) X-Google-Smtp-Source: APXvYqw1d+k9g2EOIqM56oagWgv0JQIX6J3X/1MINqpWV7eGpHWZq2CL+PdeA6mdyz5uUaiNlo0C X-Received: by 2002:a9d:7394:: with SMTP id j20mr16681996otk.273.1576266650801; Fri, 13 Dec 2019 11:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576266650; cv=none; d=google.com; s=arc-20160816; b=l1uo+tedIxkrUSsmeT2yl2oAl17HFJkqdna7PCDMpVVOtQ1PpirLwC0PeSwI36CL/D qm+N2gzkK4bv/h9pjbZG5dD5VNdCqL7Xzy0zViE8Ue/0aDgzMrDJTcUYz1jV7qhCj85B AX3yeiqZxJRkEoeacQOlnxszkIb8kmH13wrF+o2oyNLQW8bgEhCY8jLcAgP7hP9756Bn cfkCfRgqqO7MRsFi4AsGiA31dRsKAO6OWJ8h9ddl6VaxXcsJ7UHriR0OgMz3m88Dmsyl SoHe5AGIMKIgfXhemgdbyYjmg1YX2S+Nf7Xkax3yn4jdDFwTp7IJ5uF7p3DM+xSSGY5T bTHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=r+LhfcmgvQSKDNTRu0ez2f2yQJfO6RLGgqP4bH4VIfg=; b=OtqhckaYLJlIf1K54fOYG8LJKQxvpiDB5qvnpZ+DmyXs9Wih0bvMUwiuJXLEuABIOs aGrUwDSz6Bzqgxi+mXJMbnU3M9cu5OfO107UlGZjXTv4q/ftF/R/gmnrVJD9q4bSfj5G OiO2ewG9A3cuKgbUG4mpS+g0LYD1I74x4kQGhnvJmdybNkuKNGD3cYLljjWebUWXCZVq AF1fy1b+aTHwlm/zpNG3xIyAf6tUe//l4edExGlRPK9KJyBAO7zGjy5hUoJbvXQ5m8xx cxPi+XuMgIWMsuSKOsojgMKihHaAIz8xykIts7h1onm29e+ns+3XS8qGNAdsX5RrUvJt vUfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a93si5701900otc.24.2019.12.13.11.50.25; Fri, 13 Dec 2019 11:50:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728943AbfLMTtr (ORCPT + 99 others); Fri, 13 Dec 2019 14:49:47 -0500 Received: from mx2.suse.de ([195.135.220.15]:57540 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728942AbfLMTtq (ORCPT ); Fri, 13 Dec 2019 14:49:46 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 76B8EAF65; Fri, 13 Dec 2019 19:49:44 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 36FA41E0609; Fri, 13 Dec 2019 20:49:43 +0100 (CET) Date: Fri, 13 Dec 2019 20:49:43 +0100 From: Jan Kara To: Joel Fernandes Cc: Phong Tran , Jan Kara , "Theodore Y. Ts'o" , adilger.kernel@dilger.ca, "Paul E. McKenney" , linux-ext4@vger.kernel.org, LKML , linux-kernel-mentees@lists.linuxfoundation.org, rcu , stable Subject: Re: [PATCH V2] ext4: use rcu API in debug_print_tree Message-ID: <20191213194943.GA959@quack2.suse.cz> References: <20191213113510.GG15474@quack2.suse.cz> <20191213153306.30744-1-tranmanphong@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri 13-12-19 10:11:50, Joel Fernandes wrote: > On Fri, Dec 13, 2019 at 7:39 AM Phong Tran wrote: > > > > struct ext4_sb_info.system_blks was marked __rcu. > > But access the pointer without using RCU lock and dereference. > > Sparse warning with __rcu notation: > > > > block_validity.c:139:29: warning: incorrect type in argument 1 (different address spaces) > > block_validity.c:139:29: expected struct rb_root const * > > block_validity.c:139:29: got struct rb_root [noderef] * > > > > Reviewed-by: Jan Kara > > Signed-off-by: Phong Tran > > Thanks Phong! Looks like a real bug fix caught thanks to Sparse. So > let us mark for stable as well? Well, not really. The code is active only with CONFIG_EXT4_DEBUG enabled and in this case there's no race with remount (and thus sbi->system_blks changing) possible. So the change is really only to silence the sparse warning. Honza > > - Joel > > > --- > > fs/ext4/block_validity.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > --- > > change log: > > V2: Add Reviewed-by: Jan Kara > > > > diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c > > index d4d4fdfac1a6..1ee04e76bbe0 100644 > > --- a/fs/ext4/block_validity.c > > +++ b/fs/ext4/block_validity.c > > @@ -133,10 +133,13 @@ static void debug_print_tree(struct ext4_sb_info *sbi) > > { > > struct rb_node *node; > > struct ext4_system_zone *entry; > > + struct ext4_system_blocks *system_blks; > > int first = 1; > > > > printk(KERN_INFO "System zones: "); > > - node = rb_first(&sbi->system_blks->root); > > + rcu_read_lock(); > > + system_blks = rcu_dereference(sbi->system_blks); > > + node = rb_first(&system_blks->root); > > while (node) { > > entry = rb_entry(node, struct ext4_system_zone, node); > > printk(KERN_CONT "%s%llu-%llu", first ? "" : ", ", > > @@ -144,6 +147,7 @@ static void debug_print_tree(struct ext4_sb_info *sbi) > > first = 0; > > node = rb_next(node); > > } > > + rcu_read_unlock(); > > printk(KERN_CONT "\n"); > > } > > > > -- > > 2.20.1 > > -- Jan Kara SUSE Labs, CR