From patchwork Thu Dec 1 22:02:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 701712 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tVBCS1SnJz9t1B for ; Fri, 2 Dec 2016 09:04:36 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cCZRn-0008P3-0d; Thu, 01 Dec 2016 22:03:19 +0000 Received: from mail.sigma-star.at ([95.130.255.111]) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cCZRP-0008Cl-Fp for linux-mtd@lists.infradead.org; Thu, 01 Dec 2016 22:02:57 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.sigma-star.at (Postfix) with ESMTP id 810E224E0001; Thu, 1 Dec 2016 23:02:34 +0100 (CET) Received: from linux.site (richard.vpn.sigmapriv.at [10.3.0.5]) by mail.sigma-star.at (Postfix) with ESMTPSA id 8E9C616B50A6; Thu, 1 Dec 2016 23:02:33 +0100 (CET) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH 2/6] ubifs: Provide a custom llseek for directories Date: Thu, 1 Dec 2016 23:02:17 +0100 Message-Id: <1480629741-18375-3-git-send-email-richard@nod.at> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1480629741-18375-1-git-send-email-richard@nod.at> References: <1480629741-18375-1-git-send-email-richard@nod.at> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161201_140255_922983_2BDDA4B5 X-CRM114-Status: GOOD ( 13.81 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david@sigma-star.at, tytso@mit.edu, dedekind1@gmail.com, Richard Weinberger , linux-kernel@vger.kernel.org, adrian.hunter@intel.com, adilger.kernel@dilger.ca, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, linux-ext4@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 7f01f3d2ac3b..883b2fdf51df 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1721,6 +1721,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, @@ -1741,7 +1751,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