Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3099792rdh; Mon, 27 Nov 2023 06:32:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0+nW0y6jP9zWRXkqdrtCNrnOrrvCU5HnhCubszs5QNEbtIzOOroqfJGuEtQ7ocn37ICtW X-Received: by 2002:a05:6871:5824:b0:1fa:26b7:af18 with SMTP id oj36-20020a056871582400b001fa26b7af18mr8741574oac.17.1701095550246; Mon, 27 Nov 2023 06:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701095550; cv=none; d=google.com; s=arc-20160816; b=XNAaFc6cdYSdpfCwKRW13qsv1wEoDV0/0qburWUA4vzFvzzkDvgmiuSLQOOqiQDGMy iFky1+HJv6G+lfplKqsZ4ChOHG/M3up77zhK8DjfPsQTXs1gc74diYCqm60FVXDGz8GT GDSn63bls7am3SIOkk4x7r4SjkiKvLwBVKSsyR39crz2dgUMBDoV8CPsVlT4Alf9gtW1 nrX5xqYwTEJMpR730zNxTQ6G+uxxX+2+uAzkGrGL1pxGk8LXze7zHIAuF5+GpfGEGIgV vr8AazBQ/5kV4sZMAhd5suD0GJfBYC8zFSgij7MCMOUUFLaBpMQkYM3bqZ6sYVBpZPiM I/9g== 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=LSD6FwTVggzrZpf2kEN+3oSDCrGK42JmxcGcmXQsxww=; fh=c4gLbwT9pvttlQWxFI2VesWIZ95B4IQ3bBh75IOono4=; b=w4qJp0X9lbt9cmf9g/+wguIFJEIyoJY71KrDXSkAq1MpRGYUP4NB9vy6ayZbuntJX8 PsL5hqZ0NFoWszK+0K0Rr90awvt2njS5k04QTaSg1cPRYYgdmdwgmU6itRlYIy4yjDBW Sh56EMk1qRggqVzPVBA+eXVCcwAR122LXPyawx4gtLkzcsnvn4v8b9X21CQaGPZ4UhHM TGhuFjx5FmV0PI+Q6Z4E+bBtW7zGLeDaZ/raTh48U0bieWcdyy/kiv/FCjeF4hLlhA5s i2nF+DktIgZM82rvD3aDHSQM6vCM5k/T7ag//uPVAQ9dj81lE3bp+b8jkj/A3HB/rEUw bNXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KLJx8Qvm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id b13-20020a056870d1cd00b001fa48a8899csi1000721oac.21.2023.11.27.06.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KLJx8Qvm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E1A298070DBA; Mon, 27 Nov 2023 06:32:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233421AbjK0OcA (ORCPT + 99 others); Mon, 27 Nov 2023 09:32:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233780AbjK0ObU (ORCPT ); Mon, 27 Nov 2023 09:31:20 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B71D19AB; Mon, 27 Nov 2023 06:31:00 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cfa5840db3so23163715ad.2; Mon, 27 Nov 2023 06:31:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095460; x=1701700260; darn=vger.kernel.org; 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=LSD6FwTVggzrZpf2kEN+3oSDCrGK42JmxcGcmXQsxww=; b=KLJx8QvmCPcubfTBNhQxVX0gSf3HddAJQa6MM86PMg781f5bWHIEXWR9ya2pRWqB7+ 9oWo4d/dsLZsiM/Y3iOVhi43VNcRtpVLG+sd7jMLWj/sKiLoNF8S63NLf3KkLcXVgfMJ TnZJIiD9tSNMk8kYQ0l02SxGOnIY6PZR/IOV6ByHcz7xCOt5RetIzXkdG1WgoSEZq/FS o0EZjK2snzpAtyfxfaFEcSkUxr3ZcVhMsoZFuNtOpEmB/T8d2f1w8cg8hzgViAiA3osE RjYG6uuduTC0xu65OzT1gO8gIKaJDI7R31AAOb1RLyguuSi6b+zAX4kfgoDhXrV2Adbk jINw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095460; x=1701700260; 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=LSD6FwTVggzrZpf2kEN+3oSDCrGK42JmxcGcmXQsxww=; b=u80Z09Kv5SmFAuw7ITVf8WkbfcwLJOzZLudXU7t3m3dmLljAKD3OKC4zqMzRVkfwvs CQfmSz7ggwU+5nO/qrW76XY9Ay1l+eKyIWQH1dFUXFMttSYS6Q9Htdcv0QB9miCFGcwf DBT7eoV8JzFwo2dk1mIyz3l8SVH0hqLQLrQ6iklE1AsACEns0aLk+Hs1QbgKikR4k3g5 CoUNn9Yitkz7OfkZ/yT9kCWz9d394NScTXtD/8ysR+e3N1Bm75Vq/q+8CTT1ydb9PT74 HSDTYsiOtFl8hOV0AXG5yicbFnGn9fW6+IM0ZCo96Na8Sz1Ap/4/ORpgrjgHpvAMFoQK kPgQ== X-Gm-Message-State: AOJu0YwvnsaYzaTZO2tfk9QFuzKTW9YlHQh3B6G9QKofskHry9cTpaV8 P6DxrQ0N+DTwwTSZNO3rLac= X-Received: by 2002:a17:903:41ce:b0:1cf:c3fb:a982 with SMTP id u14-20020a17090341ce00b001cfc3fba982mr5966951ple.63.1701095459732; Mon, 27 Nov 2023 06:30:59 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:30:59 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 06/17] nilfs2: Return the mapped address from nilfs_get_page() Date: Mon, 27 Nov 2023 23:30:25 +0900 Message-Id: <20231127143036.2425-7-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 27 Nov 2023 06:32:25 -0800 (PST) From: "Matthew Wilcox (Oracle)" In prepartion for switching from kmap() to kmap_local(), return the kmap address from nilfs_get_page() instead of having the caller look up page_address(). [ konishi.ryusuke: fixed a missing blank line after declaration ] Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 57 +++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 385e47eda99f..45f75d4c4522 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -180,19 +180,24 @@ static bool nilfs_check_page(struct page *page) return false; } -static struct page *nilfs_get_page(struct inode *dir, unsigned long n) +static void *nilfs_get_page(struct inode *dir, unsigned long n, + struct page **pagep) { struct address_space *mapping = dir->i_mapping; struct page *page = read_mapping_page(mapping, n, NULL); + void *kaddr; - if (!IS_ERR(page)) { - kmap(page); - if (unlikely(!PageChecked(page))) { - if (!nilfs_check_page(page)) - goto fail; - } + if (IS_ERR(page)) + return page; + + kaddr = kmap(page); + if (unlikely(!PageChecked(page))) { + if (!nilfs_check_page(page)) + goto fail; } - return page; + + *pagep = page; + return kaddr; fail: nilfs_put_page(page); @@ -269,14 +274,14 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) for ( ; n < npages; n++, offset = 0) { char *kaddr, *limit; struct nilfs_dir_entry *de; - struct page *page = nilfs_get_page(inode, n); + struct page *page; - if (IS_ERR(page)) { + kaddr = nilfs_get_page(inode, n, &page); + if (IS_ERR(kaddr)) { nilfs_error(sb, "bad page in #%lu", inode->i_ino); ctx->pos += PAGE_SIZE - offset; return -EIO; } - kaddr = page_address(page); de = (struct nilfs_dir_entry *)(kaddr + offset); limit = kaddr + nilfs_last_byte(inode, n) - NILFS_DIR_REC_LEN(1); @@ -339,11 +344,9 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, start = 0; n = start; do { - char *kaddr; + char *kaddr = nilfs_get_page(dir, n, &page); - page = nilfs_get_page(dir, n); - if (!IS_ERR(page)) { - kaddr = page_address(page); + if (!IS_ERR(kaddr)) { de = (struct nilfs_dir_entry *)kaddr; kaddr += nilfs_last_byte(dir, n) - reclen; while ((char *) de <= kaddr) { @@ -381,15 +384,11 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct page **p) { - struct page *page = nilfs_get_page(dir, 0); - struct nilfs_dir_entry *de = NULL; + struct nilfs_dir_entry *de = nilfs_get_page(dir, 0, p); - if (!IS_ERR(page)) { - de = nilfs_next_entry( - (struct nilfs_dir_entry *)page_address(page)); - *p = page; - } - return de; + if (IS_ERR(de)) + return NULL; + return nilfs_next_entry(de); } ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr) @@ -451,12 +450,11 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) for (n = 0; n <= npages; n++) { char *dir_end; - page = nilfs_get_page(dir, n); - err = PTR_ERR(page); - if (IS_ERR(page)) + kaddr = nilfs_get_page(dir, n, &page); + err = PTR_ERR(kaddr); + if (IS_ERR(kaddr)) goto out; lock_page(page); - kaddr = page_address(page); dir_end = kaddr + nilfs_last_byte(dir, n); de = (struct nilfs_dir_entry *)kaddr; kaddr += PAGE_SIZE - reclen; @@ -618,11 +616,10 @@ int nilfs_empty_dir(struct inode *inode) char *kaddr; struct nilfs_dir_entry *de; - page = nilfs_get_page(inode, i); - if (IS_ERR(page)) + kaddr = nilfs_get_page(inode, i, &page); + if (IS_ERR(kaddr)) continue; - kaddr = page_address(page); de = (struct nilfs_dir_entry *)kaddr; kaddr += nilfs_last_byte(inode, i) - NILFS_DIR_REC_LEN(1); -- 2.34.1