Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp235054imu; Tue, 8 Jan 2019 18:40:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN4MvBNQ9kXwszqttB0wBmfs7Bqcd6HUNzma1VRYQbPMoGiZAHS4f3Y21ioVbTkBSJOF+U5J X-Received: by 2002:a62:56c7:: with SMTP id h68mr4410720pfj.134.1547001610524; Tue, 08 Jan 2019 18:40:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547001610; cv=none; d=google.com; s=arc-20160816; b=ORWIvfb1uR6EV32Uuww/zs9G2DjNKPoS3cMvujMt/smDx9sLQ6DDgBI0Mln0vm8mnK 5foyDZajt7+DGOphSI2PYko2rwCMlaQ7hmH4PHmgCixgeGO7W8yaUrxb/UkFyD6dURuT jUA3dTLUXwOCfq3YrHk93NDizi4PdZUixGDi9pRd778lXEBn+zeKUPUOJcqa8CVHmDkz GJ3D27J8znhdKnURTNuBPtF4jK4aH7VbCqzgN0qdQKiuzGx2+JaRPd2oEtrqpMfU0msc rDvPwJx4SflTLA+J+KkfCbv+E+oYLKIL63rbWuuGMI532VbEHFzIXcVjehgLPSUr0Z6e QWpA== 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=nLg5kdwDPi5itOxM8J9BEwoOYxwv/B/0wueUuK5ID4c=; b=H1I5lEAQ7bA2zvqUtIb/d/RC5v1uRHxRfQ2gnAWvuuQe/39kHDjuUqcJqgrf9oMp0t kwp6NRR1g3PmJiVVb8i9Mnhf8rk9yFQcGU7FRgJvfcsi94IlTuhV+C63NRHZScXm4n/l Y/gztVNyRultV/1/Mv5lpoL7wMMOeKodkDaTs+NpaTVmX3jdbJMZPUszZcepJWlOHiLt RWKQJSMCOgbUbL3r6MRtLlwm4Xx/YYx27dx+fQ2oiTzIvK5RSRNnGVVgpvKZ0u6rduxP yvgZ9xennY+tBh99BZv++StTLl82ctfea6V1Ag4oNcAhYz0EbwNT382OCLet+JAsSu2z ZoRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 63si58922639pfv.38.2019.01.08.18.39.54; Tue, 08 Jan 2019 18:40:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729297AbfAICiu (ORCPT + 99 others); Tue, 8 Jan 2019 21:38:50 -0500 Received: from nautica.notk.org ([91.121.71.147]:38592 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727917AbfAICit (ORCPT ); Tue, 8 Jan 2019 21:38:49 -0500 Received: by nautica.notk.org (Postfix, from userid 1001) id AC4A7C01B; Wed, 9 Jan 2019 03:38:47 +0100 (CET) Date: Wed, 9 Jan 2019 03:38:32 +0100 From: Dominique Martinet To: Hou Tao Cc: v9fs-developer@lists.sourceforge.net, lucho@ionkov.net, ericvh@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, xingaopeng@huawei.com Subject: Re: [PATCH] 9p: use inode->i_lock to protect i_size_write() Message-ID: <20190109023832.GA12389@nautica> References: <20190109020522.105713-1-houtao1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190109020522.105713-1-houtao1@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hou Tao wrote on Wed, Jan 09, 2019: > Use inode->i_lock to protect i_size_write(), else i_size_read() in > generic_fillattr() may loop infinitely when multiple processes invoke > v9fs_vfs_getattr() or v9fs_vfs_getattr_dotl() simultaneously under > 32-bit SMP environment, and a soft lockup will be triggered as show below: Hmm, I'm not familiar with the read/write seqcount code for 32 bit but I don't understand how locking here helps besides slowing things down (so if the value is constantly updated, the read thread might have a chance to be scheduled between two updates which was harder to do before ; and thus "solving" your soft lockup) Instead, a better fix would be to update v9fs_stat2inode to first read the inode size, and only call i_size_write if it changed - I'd bet this also fixes the problem and looks better than locking to me. (Can also probably reuse stat->length instead of the following i_size_read for i_blocks...) On the other hand it might make sense to also lock the inode for stat2inode because we're dealing with partially updated inodes at time, but if we do this I'd rather put the locking in v9fs_stat2inode and not outside of it to catch all the places where it's used; but the readers don't lock so I'm not sure it makes much sense. There's also a window during which the inode's nlink is dropped down to 1 then set again appropriately if the extension is present; that's rather ugly and we probably should only reset it to 1 if the attribute wasn't set before... That can be another patch and/or I'll do it eventually if you don't. I hope what I said makes sense. Thanks, -- Dominique Martinet | Asmadeus