Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8158168rwl; Sat, 31 Dec 2022 00:13:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXvrEu5tdnlsTRrmlMSbGHmS4TMv5QeZpHK0Av5VsH0fyV+AEVgNLXd4qaUmgAoEnBfrlCmA X-Received: by 2002:aa7:cd04:0:b0:479:7026:b992 with SMTP id b4-20020aa7cd04000000b004797026b992mr26937218edw.38.1672474394604; Sat, 31 Dec 2022 00:13:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672474394; cv=none; d=google.com; s=arc-20160816; b=rskDgWb8roo8jhF5gyfuG3BtGvQ+ZOE2yfex96MGBmtgTgUDYxgH0yvswiHSskWiO0 lXXk7T0lzY8+zfgWRXKGMX4s7gxbvcyb5qbObEJtkupFtJdIDiATT19ZFQySCyOtN8nq AnQd/quTbOWRqodPf9VvrLfgzPkVcYS21Y0Nd3ubB4wUtlNVa/eQINbgAmD2mUaXtviA y6lxxxsqzjtNnfCnaYNSrxJYZy1oAiqEwR6xF8UPL6PdJ1skAbmppVJOOVkKsOPWJ7xK ccfl+mFym/fIkag/E9EkR5EU3+GdA/8TUoaSL/nZYAXJySiLLeueMNDdn7y+QYBQbKie Ow2Q== 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=t4IpF0CMnhbBf7H7iLN0nfh/18GS/Ps3ATwtaps4Vp8=; b=SkE2206LqxTXix/28OtYuEiY3K0ppyNGXaplI5nR6ryB3LZO0gMJ3EzkkeA9Rc5C8m aROtD4pLu08A1hlBkc14IRHTVvdx/6YghBRn+VUjrjNu4j3wBzXfqjIxl0wYC3EPumzT qiPxYwM9k9nBYJNyB53aIwvpPBkoxcfUXDLJqumn+hIiB8ANPoo5aP0BIF43R6wkIw0U yVmMBIvRvdjDJYT952Qs4nG9tCT+CN9h4Xd6BqFJz9iIl3G3L/1P5Zy/WZD96p1WN8lf plwLCC5u1v9bT/+gPR8/MqBV7MySBKBOen9fDM9SWSuY4VJr9T5jBK1HEZ2SLPqlSeW6 /TIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AOl7o3fm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8-20020a056402038800b00487ceac6d34si8258058edv.137.2022.12.31.00.12.58; Sat, 31 Dec 2022 00:13:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AOl7o3fm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231626AbiLaH5b (ORCPT + 63 others); Sat, 31 Dec 2022 02:57:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbiLaH50 (ORCPT ); Sat, 31 Dec 2022 02:57:26 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6020CD9D; Fri, 30 Dec 2022 23:57:25 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id fm16-20020a05600c0c1000b003d96fb976efso14843220wmb.3; Fri, 30 Dec 2022 23:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t4IpF0CMnhbBf7H7iLN0nfh/18GS/Ps3ATwtaps4Vp8=; b=AOl7o3fmt3GWKSukWb8eLrplMvNc8lqZmXLnm8MPUxTsxPucV3/hhW063eGVE1JXg/ tFrop3VJAz0M3OYKgqncR0UuoMlCV/SJ7vy/NHDNuQsFkfuzyMsecph3+tzNMNPeQ+Uk bjpujoOPzTGGa3PaaODY9yWrdaUw/p1tluWLd4suv34ZqrEEDf+o2AAJ94McrOoA9SGN tIifYv3uoqRq4Mw8c4+MxJkSX8CrwMAdZJ3ssvjo/5K9lieSW8cbD2WgLUUPm5yYSYq3 S4ysG2PlRxt9fT73c5m2Dt8fFKzJEB0IkVzJvMw7UcCkmF8lEOKlgifqe2f3Dc0OZWav SI4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t4IpF0CMnhbBf7H7iLN0nfh/18GS/Ps3ATwtaps4Vp8=; b=DLhlfuP4hcpsxauMgEwphMkYRL7ax9AeGBviKFWfUNnX2UqKHW7oF9QoYs7FdrS1PV WxkFilmACUcuV+NV7c5nnNs2iVCDVhwZlhYJvLN8JhtyAdW2kJleaeNrMtTE2QsVROwv cII6YBa4JXOAOLwrig/a+hGwOH56HIZTqyARnAMgPrM4UMS6thQzL4FGZxzKM4iu40gF 9x2SZVe8fPPQe8DE86U7UiBXdAZHsN7mk7TzBB34bPOZk1itArmANP8bYGaM4Gtz1Zok G7mmkZMps/EjjlOBjukBMtZ1tuTy1vXuGdECxacAT9e1dtoBjbtxOWYArZrpn4akbThH 8ufQ== X-Gm-Message-State: AFqh2ko8YtVZ99p26ZRXxf+2G4BLlVuGm9PfIxmsEB9VcMBYei9nsxyz 2QrjS/raTsBxKF+/CjKpouencRbMzBc= X-Received: by 2002:a05:600c:a13:b0:3d0:2485:c046 with SMTP id z19-20020a05600c0a1300b003d02485c046mr24077127wmp.27.1672473443870; Fri, 30 Dec 2022 23:57:23 -0800 (PST) Received: from localhost.localdomain (host-79-56-217-20.retail.telecomitalia.it. [79.56.217.20]) by smtp.gmail.com with ESMTPSA id l42-20020a05600c1d2a00b003d23928b654sm39389232wms.11.2022.12.30.23.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 23:57:23 -0800 (PST) From: "Fabio M. De Francesco" To: Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: "Fabio M. De Francesco" , Ira Weiny , Al Viro Subject: [PATCH 1/4] fs/sysv: Use the offset_in_page() helper Date: Sat, 31 Dec 2022 08:57:14 +0100 Message-Id: <20221231075717.10258-2-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221231075717.10258-1-fmdefrancesco@gmail.com> References: <20221231075717.10258-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the offset_in_page() helper because it is more suitable than doing explicit subtractions between pointers to directory entries and kernel virtual addresses of mapped pages. Cc: Ira Weiny Suggested-by: Al Viro Signed-off-by: Fabio M. De Francesco --- fs/sysv/dir.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 88e38cd8f5c9..685379bc9d64 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -206,8 +206,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) return -EINVAL; got_it: - pos = page_offset(page) + - (char*)de - (char*)page_address(page); + pos = page_offset(page) + offset_in_page(de); lock_page(page); err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); if (err) @@ -230,8 +229,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page) { struct inode *inode = page->mapping->host; - char *kaddr = (char*)page_address(page); - loff_t pos = page_offset(page) + (char *)de - kaddr; + loff_t pos = page_offset(page) + offset_in_page(de); int err; lock_page(page); @@ -328,8 +326,7 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page, struct inode *inode) { struct inode *dir = page->mapping->host; - loff_t pos = page_offset(page) + - (char *)de-(char*)page_address(page); + loff_t pos = page_offset(page) + offset_in_page(de); int err; lock_page(page); -- 2.39.0