From patchwork Sun May 21 20:20:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 9739377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7EEA36034C for ; Sun, 21 May 2017 20:22:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F1D624151 for ; Sun, 21 May 2017 20:22:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63BE728358; Sun, 21 May 2017 20:22:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCB6F28323 for ; Sun, 21 May 2017 20:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932372AbdEUUWi (ORCPT ); Sun, 21 May 2017 16:22:38 -0400 Received: from mail.sigma-star.at ([95.130.255.111]:45998 "EHLO mail.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756818AbdEUUVT (ORCPT ); Sun, 21 May 2017 16:21:19 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.sigma-star.at (Postfix) with ESMTP id 7999324E0005; Sun, 21 May 2017 22:21:14 +0200 (CEST) Received: from linux.site (richard.vpn.sigmapriv.at [10.3.0.5]) by mail.sigma-star.at (Postfix) with ESMTPSA id 6684724E0001; Sun, 21 May 2017 22:21:13 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Cc: david@sigma-star.at, dedekind1@gmail.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, adilger.kernel@dilger.ca, akpm@linux-foundation.org, linux-ext4@vger.kernel.org, bfields@redhat.com, marcus.folkesson@gmail.com, hyc.lee@gmail.com, rockdotlee@gmail.com, leon.pollak@gmail.com, Richard Weinberger Subject: [PATCH 2/6] ubifs: Provide a custom llseek for directories Date: Sun, 21 May 2017 22:20:47 +0200 Message-Id: <1495398051-4604-3-git-send-email-richard@nod.at> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1495398051-4604-1-git-send-email-richard@nod.at> References: <1495398051-4604-1-git-send-email-richard@nod.at> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When UBIFS is using 64bit cookies for directory offsets, we have to support seeking that deep into direcoties. Since generic_file_llseek() is uses sb->s_maxbytes it will fail for use because on ubifs sb->s_maxbytes is the real maxmal file size which can be much smaller than 64bit due to limitations of the flash device. Therefore provie a custom llseek operation. Signed-off-by: Richard Weinberger --- fs/ubifs/dir.c | 12 +++++++++++- fs/ubifs/ubifs-media.h | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 566079d9b402..cada60690c22 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1686,6 +1686,16 @@ static int ubifs_dir_open(struct inode *dir, struct file *file) return 0; } +static loff_t ubifs_dir_llseek(struct file *file, loff_t offset, int whence) +{ + struct inode *inode = file->f_mapping->host; + + return generic_file_llseek_size(file, offset, whence, + (loff_t)UBIFS_S_KEY_HASH_MASK << + UBIFS_DH_BITS | UBIFS_DH_MASK, + i_size_read(inode)); +} + const struct inode_operations ubifs_dir_inode_operations = { .lookup = ubifs_lookup, .create = ubifs_create, @@ -1706,7 +1716,7 @@ const struct inode_operations ubifs_dir_inode_operations = { }; const struct file_operations ubifs_dir_operations = { - .llseek = generic_file_llseek, + .llseek = ubifs_dir_llseek, .release = ubifs_dir_release, .read = generic_read_dir, .iterate_shared = ubifs_readdir, diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h index e8c23c9d4f4a..5939776c7359 100644 --- a/fs/ubifs/ubifs-media.h +++ b/fs/ubifs/ubifs-media.h @@ -214,6 +214,12 @@ enum { #define UBIFS_S_KEY_HASH_MASK UBIFS_S_KEY_BLOCK_MASK /* + * We use 32 bits for the double hash cookie. + */ +#define UBIFS_DH_MASK 0xffffffff +#define UBIFS_DH_BITS 32 + +/* * Key types. * * UBIFS_INO_KEY: inode node key