Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1304204rbb; Mon, 26 Feb 2024 05:31:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUPdYkOe2MntcWqYEfjRp4wXfEbIedmWQFcV3levvd+anJWopGFJ6uLq9fYPAe6Ty8GuGp1gu3G9aNQoox5J5fKhOpr4nfVvTF3T4BcVg== X-Google-Smtp-Source: AGHT+IFD55ymc2/2RseINfoWzhdRcxWxxxquUOJ8XGMs2SsQ49j5kysEi8vi9/nYqleqriBZDnRU X-Received: by 2002:a05:6358:e49d:b0:17a:b810:aacf with SMTP id by29-20020a056358e49d00b0017ab810aacfmr8436778rwb.18.1708954272010; Mon, 26 Feb 2024 05:31:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708954271; cv=pass; d=google.com; s=arc-20160816; b=q5HQrGNcGKGU2YPWSs/PLDdDh/PUDZLaQ2U30C89vT/WCFNmC/kOBpzY8LFWxA/vvd 0/qD0iBIfl8sBvB6vY18C9WGKT7cWed2QwoGefwReDCi8GYM/yzjc9LyYTPoPubqZmKl POGR4vnsiZf9kTsRT+Nhn6x805bTuwOwcfuwiC4HdsIf4cdHALJu7lOrTiODvgvcbe93 DYoWpD+iXWX+qab27Bcw5eJZ+cwrdeNGQ/Et7AL9aocheA2MoX8tY6PfLQn+DKNolnQr MX+l6qLt1AOJ2NKxNp3RWjK1wJXd0Apg2ep0i9AReYj99KoBt9vqxrK4AGqdX/EFbMBi /+Sg== 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=pqLe7YkJC6VyAQT6P/X+JQdoTmknS6YGthaSLEoDQF4=; fh=NxEgvf8Rw6A11ITJWFIYtOfb5rphg3RFyVjPJ/rcJm4=; b=LGC52OWZt2yyQ8n0kcyJeE4px92o9KxCqNd68mmFtXHXtrw13nFpx5ZtJ79nqb/Oyg 1/8ORXF7G4L1/0p85Oy1Z2XL0WtSuK+9QDbDLITQHd8EAww9D2OtwjpAx9W2riqwXqoe OTky26fOewUghxNHpb5zN4NETGkySGrDny9nMBjejjORmYJOh868qWcSQmVrHyYOfPCT ofbPfFlA1H20oRI2fjTOOx6QkBzqCueVrVThE5rnWWF6MUdOCT5z/cd2Us2gt7lVQ2Lo IYnW45vj7+xofZ5DPCGzTG2KZ/s3cEcwSXamxUy4rqU7gT2EsSpHsGYTPy7i8hhia0qn egDQ==; 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-81489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m18-20020ac84452000000b0042c72478d20si4988789qtn.70.2024.02.26.05.31.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:31:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::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-81489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81489-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 07F021C25836 for ; Mon, 26 Feb 2024 13:30:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E82C1292C9; Mon, 26 Feb 2024 13:30:44 +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 C7286128368; Mon, 26 Feb 2024 13:30:41 +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=1708954244; cv=none; b=h7Fin6XOyAfKsfOr5+CzaOhk4+KVD9wW+usUweDCNtCuDFXCoG8LcA+5Vzindu5RU/XunTDONtZx4kxh6uGvf2HBoZRmDca8PdIj9c9t4LeEImbPYd8TJy8LFttlCCuPb0SbVm/26nTcc92ZI53hWUM9gLOUKnLPy7PwLRc7vUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954244; c=relaxed/simple; bh=WmTzU75gfsPPhSRwgy0QA82m5EmwYSqwqUgyS5HWrKI=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RbyJ/r2VmvhrVfZ8LBiwbfWG/+WFlOZHhXpvnMgAcdLTwwKDr4rplq+SqjGSxNNqbwtHJGlhZcwFaDKivjQk47wtlbxpiyUBvj0Rpcpw9UW/P6qBFPNOB2IYGvm2TheJzIODqLRyu9cqfvVwh96eRaReq5iKeFxtQH7OENo/820= 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.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Tk1bd08dZz6K5wc; Mon, 26 Feb 2024 21:26:21 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 13A2A140A70; Mon, 26 Feb 2024 21:30:40 +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:30:39 +0000 Date: Mon, 26 Feb 2024 13:30:38 +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 13/20] famfs: Add iomap_ops Message-ID: <20240226133038.00006e23@Huawei.com> In-Reply-To: <2996a7e757c3762a9a28c789645acd289f5f7bc0.1708709155.git.john@groves.net> References: <2996a7e757c3762a9a28c789645acd289f5f7bc0.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: lhrpeml500001.china.huawei.com (7.191.163.213) To lhrpeml500005.china.huawei.com (7.191.163.240) On Fri, 23 Feb 2024 11:41:57 -0600 John Groves wrote: > This commit introduces the famfs iomap_ops. When either > dax_iomap_fault() or dax_iomap_rw() is called, we get a callback > via our iomap_begin() handler. The question being asked is > "please resolve (file, offset) to (daxdev, offset)". The function > famfs_meta_to_dax_offset() does this. > > The per-file metadata is just an extent list to the > backing dax dev. The order of this resolution is O(N) for N > extents. Note with the current user space, files usually have > only one extent. > > Signed-off-by: John Groves > --- > fs/famfs/famfs_file.c | 245 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 245 insertions(+) > create mode 100644 fs/famfs/famfs_file.c > > diff --git a/fs/famfs/famfs_file.c b/fs/famfs/famfs_file.c > new file mode 100644 > index 000000000000..fc667d5f7be8 > --- /dev/null > +++ b/fs/famfs/famfs_file.c > @@ -0,0 +1,245 @@ > +static int > +famfs_meta_to_dax_offset( > + struct inode *inode, > + struct iomap *iomap, > + loff_t offset, > + loff_t len, > + unsigned int flags) > +{ > + struct famfs_file_meta *meta = (struct famfs_file_meta *)inode->i_private; i_private is void * so no need for explicit cast (C spec says this is always fine without) > + > +/** > + * famfs_iomap_begin() > + * > + * This function is pretty simple because files are > + * * never partially allocated > + * * never have holes (never sparse) > + * * never "allocate on write" > + */ > +static int > +famfs_iomap_begin( > + struct inode *inode, > + loff_t offset, > + loff_t length, > + unsigned int flags, > + struct iomap *iomap, > + struct iomap *srcmap) > +{ > + struct famfs_file_meta *meta = inode->i_private; > + size_t size; > + int rc; > + > + size = i_size_read(inode); > + > + WARN_ON(size != meta->file_size); > + > + rc = famfs_meta_to_dax_offset(inode, iomap, offset, length, flags); > + > + return rc; return famfs_meta_... > +} > +static vm_fault_t > +famfs_filemap_map_pages( > + struct vm_fault *vmf, > + pgoff_t start_pgoff, > + pgoff_t end_pgoff) > +{ > + vm_fault_t ret; > + > + ret = filemap_map_pages(vmf, start_pgoff, end_pgoff); > + return ret; return filename_map_pages().... > +} > + >