From patchwork Fri May 5 18:39:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13232964 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53E2DC77B7C for ; Fri, 5 May 2023 18:39:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1EBA6B0099; Fri, 5 May 2023 14:39:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCEC56B009A; Fri, 5 May 2023 14:39:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE5326B009C; Fri, 5 May 2023 14:39:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by kanga.kvack.org (Postfix) with ESMTP id B910F6B0099 for ; Fri, 5 May 2023 14:39:46 -0400 (EDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6CDAC61338; Fri, 5 May 2023 18:39:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72C52C4339E; Fri, 5 May 2023 18:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683311985; bh=mnpCJnLWNfPkHxmM+u+UF6L43j8pKp55GRe3BbzShFc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=dt/3WmZqawbotPuR4zhXODVMzgAQJFtU6w6auHJr1A7S+XkIzFtfFk+q3ptGu8yR8 2iixaLu4XVTftOxrRSLTgQevQ3/bOiMNHtq7y/CWsi313PFGm2eC7sEbNmx60QtXrA yyx4yTPvgWCC71x28BXwfyT9VTO6l/mFyKEmjD5MsqLEY/9hM5+rOcYIloJO8H5cws WA1E+KHEHpO2/R6KGY37mcuIbJd1YAkDZxwk9btgWSOYM9lust1gHRgSfK8uc+nQ7J 5pTwMUvw2+WXyKy4VYxnu69W5Ydf4amfrsCvz7tzrC3j1fz+VFn0f6D57AvLXOxSdZ q2DdnRsZplhuQ== Subject: [PATCH v2 4/5] shmem: Add a shmem-specific dir_emit helper From: Chuck Lever To: hughd@google.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Fri, 05 May 2023 14:39:34 -0400 Message-ID: <168331196437.20728.1655558228044135552.stgit@oracle-102.nfsv4bat.org> In-Reply-To: <168331111400.20728.2327812215536431362.stgit@oracle-102.nfsv4bat.org> References: <168331111400.20728.2327812215536431362.stgit@oracle-102.nfsv4bat.org> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Chuck Lever Clean up to improve the readability of shmem_readdir(). Signed-off-by: Chuck Lever --- mm/shmem.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index b78253996108..733b98ca8517 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3329,6 +3329,15 @@ static loff_t shmem_dir_llseek(struct file *file, loff_t offset, int whence) return offset; } +static bool shmem_dir_emit(struct dir_context *ctx, struct dentry *dentry) +{ + struct inode *inode = d_inode(dentry); + + return ctx->actor(ctx, dentry->d_name.name, dentry->d_name.len, + ctx->pos, inode->i_ino, + fs_umode_to_dtype(inode->i_mode)); +} + /** * shmem_readdir - Emit entries starting at offset @ctx->pos * @file: an open directory to iterate over @@ -3369,9 +3378,7 @@ static int shmem_readdir(struct file *file, struct dir_context *ctx) return 0; while ((next = scan_positives(cursor, p, 1, next)) != NULL) { - if (!dir_emit(ctx, next->d_name.name, next->d_name.len, - d_inode(next)->i_ino, - fs_umode_to_dtype(d_inode(next)->i_mode))) + if (!shmem_dir_emit(ctx, dentry)) break; ctx->pos++; p = &next->d_child;