Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1314988rbb; Mon, 26 Feb 2024 05:50:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWuGM+uD2M3ZHMBh/TUKoq8GZ7xs+73cnwnyX2gD9lpS/wk15eoIyjzxpvxcDYAShjEOizCyXYEMYgOl8d0vE7f962hIzPzJVM131H+Kg== X-Google-Smtp-Source: AGHT+IHw8+lgRvRGxfUXApx2GJ5Qjg7CIyPDm9OJi/ZdhFqq3Heu/7vthHqVcahe7g1OO1H2b2Go X-Received: by 2002:a05:6a00:1ca4:b0:6e4:d201:a39a with SMTP id y36-20020a056a001ca400b006e4d201a39amr7279347pfw.22.1708955456850; Mon, 26 Feb 2024 05:50:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708955456; cv=pass; d=google.com; s=arc-20160816; b=lTzZVJ41qmYFoOYVhyyZwCKpL/RCejGVtqMPFKhostEtc3DEkUYQ3//fdwaLgVXWG6 3kpjykRMsuwTKJo+kFY2jl2hqkWd9LWXk2S78Nrajj6bdEYCDDA9P2fhGmi62KYoLyHq F7k7nvKTQ7it/Mu8hEvQ7T5e8CIs0GBSVSvcb0/3YllSK8DwtFZoOpjDgQcuV8eKKl9M 8J2tr33rbc0gbzQGlO5HfpVTo4VnIrWixA+TDdWBAULI+YRbAaT0UnZcrzVhUsu7g+45 CAg0DBkEDTOHZbh9PqAjKAIRmMBl1zl6XC8V7tCTwUK6nt+LBP1+/pUzDvhzEUgH1chb 4aXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=RdASsf62k73BuAYu9N8FUYoIASuS/f4Io7k38UeuxG0=; fh=NxEgvf8Rw6A11ITJWFIYtOfb5rphg3RFyVjPJ/rcJm4=; b=GjsPDg3X/dU6U8BsSiMPHcswnDBg+0crD3mCtawsZbHnB2p4Ti8VyTE3eMOceFT2tH nY+Yn5NpHHNFwXHnWLQOwzJY5C60DKXfGXjmrssx0yWbyiWg5vj0t7HOsMCKsfhS1NJ4 Os82qv2Yqi6s7H5ahcvbB/v3HuAIFWeGhBU4EYdFtEK+SOt4xXPfsMCKpqqo/lyw4ifo jwaoyOJZzPhhpDs5MeUlx5U4NkOBdxDKfFoGcdXu+df9JZ1sU3+G6jwrTVvNsQDdWUPD yNHzjU5AioThjRfz0BWKlNd2xPflhOVd59s7ZSa7wM967xn4XkpUDKstENzF0XFIgcJa s4pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-81492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h10-20020a056a00230a00b006e46627907asi3742744pfh.4.2024.02.26.05.50.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:50:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-81492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 59FFEB22E21 for ; Mon, 26 Feb 2024 13:32:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D39FE1292CA; Mon, 26 Feb 2024 13:32:43 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BB4A128379; Mon, 26 Feb 2024 13:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954363; cv=none; b=W4RrYA5iq/sGRJUQDsCne1CuPnaNPDS+Y28fGnwCeF2U1Lui4u1FzxP9EKD13n+An3MbEdz1ix/53teNcHdmD+1YkKvDCgUz4VzcSmA6P5Mq/zssZmwA8f7LbAYPXvD9hn9GEB4vULO1Px8fvA56jFOFGxC2C8YkCBc0SvQZSic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954363; c=relaxed/simple; bh=/neKbunxHrwE+xaiaF0X+DGLLLiJ5WALdtQrSvjEPEc=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BLDsJHtB77EUHQlQSGfLQQy4/SwGN0stnllM3OmmtAiqiQT3QRkLtseT37b+Szf99WZzsbGOW9eCDVsptqkRoOHSFblr/zCDZLEZyzIUuTYg6LFN4LcxkZ1k7KG11rIwZDUM4t4kys+z3j0qQfSHaM7W3YyLJvvZMcKdij4qvRg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Tk1dc2nRcz6JBTf; Mon, 26 Feb 2024 21:28:04 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 8FD251400DB; Mon, 26 Feb 2024 21:32:38 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 26 Feb 2024 13:32:37 +0000 Date: Mon, 26 Feb 2024 13:32:37 +0000 From: Jonathan Cameron To: John Groves CC: John Groves , Jonathan Corbet , "Dan Williams" , Vishal Verma , Dave Jiang , "Alexander Viro" , Christian Brauner , "Jan Kara" , Matthew Wilcox , , , , , , , Dave Chinner , Christoph Hellwig , , Subject: Re: [RFC PATCH 14/20] famfs: Add struct file_operations Message-ID: <20240226133237.0000593c@Huawei.com> In-Reply-To: <3f19cd8daab0dc3c4d0381019ce61cd106970097.1708709155.git.john@groves.net> References: <3f19cd8daab0dc3c4d0381019ce61cd106970097.1708709155.git.john@groves.net> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To lhrpeml500005.china.huawei.com (7.191.163.240) On Fri, 23 Feb 2024 11:41:58 -0600 John Groves wrote: > This commit introduces the famfs file_operations. We call > thp_get_unmapped_area() to force PMD page alignment. Our read and > write handlers (famfs_dax_read_iter() and famfs_dax_write_iter()) > call dax_iomap_rw() to do the work. > > famfs_file_invalid() checks for various ways a famfs file can be > in an invalid state so we can fail I/O or fault resolution in those > cases. Those cases include the following: > > * No famfs metadata > * file i_size does not match the originally allocated size > * file is not flagged as DAX > * errors were detected previously on the file > > An invalid file can often be fixed by replaying the log, or by > umount/mount/log replay - all of which are user space operations. > > Signed-off-by: John Groves > --- > fs/famfs/famfs_file.c | 136 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 136 insertions(+) > > diff --git a/fs/famfs/famfs_file.c b/fs/famfs/famfs_file.c > index fc667d5f7be8..5228e9de1e3b 100644 > --- a/fs/famfs/famfs_file.c > +++ b/fs/famfs/famfs_file.c > @@ -19,6 +19,142 @@ > #include > #include "famfs_internal.h" > > +/********************************************************************* > + * file_operations > + */ > + > +/* Reject I/O to files that aren't in a valid state */ > +static ssize_t > +famfs_file_invalid(struct inode *inode) > +{ > + size_t i_size = i_size_read(inode); > + struct famfs_file_meta *meta = inode->i_private; > + > + if (!meta) { > + pr_err("%s: un-initialized famfs file\n", __func__); > + return -EIO; > + } > + if (i_size != meta->file_size) { > + pr_err("%s: something changed the size from %ld to %ld\n", > + __func__, meta->file_size, i_size); > + meta->error = 1; > + return -ENXIO; > + } > + if (!IS_DAX(inode)) { > + pr_err("%s: inode %llx IS_DAX is false\n", __func__, (u64)inode); > + meta->error = 1; > + return -ENXIO; > + } > + if (meta->error) { > + pr_err("%s: previously detected metadata errors\n", __func__); > + meta->error = 1; Already set? If treating it as only a boolean, maybe make it one? > + return -EIO; > + } > + return 0; > +}