From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05EBEC433E1 for ; Mon, 27 Jul 2020 01:50:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D904420759 for ; Mon, 27 Jul 2020 01:50:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbgG0Buo (ORCPT ); Sun, 26 Jul 2020 21:50:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbgG0Buo (ORCPT ); Sun, 26 Jul 2020 21:50:44 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30E9DC0619D2; Sun, 26 Jul 2020 18:50:44 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzsHm-003LpT-3z; Mon, 27 Jul 2020 01:50:38 +0000 Date: Mon, 27 Jul 2020 02:50:38 +0100 From: Al Viro To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, "H. Peter Anvin" , Song Liu , Linus Torvalds , linux-raid@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 12/23] initrd: switch initrd loading to struct file based APIs Message-ID: <20200727015038.GA795125@ZenIV.linux.org.uk> References: <20200714190427.4332-1-hch@lst.de> <20200714190427.4332-13-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200714190427.4332-13-hch@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jul 14, 2020 at 09:04:16PM +0200, Christoph Hellwig wrote: > static int __init > -identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor) > +identify_ramdisk_image(struct file *file, int start_block, > + decompress_fn *decompressor) > { .... > - ksys_lseek(fd, start_block * BLOCK_SIZE, 0); > kfree(buf); > return nblocks; > } You do realize that you've changed behaviour of that thing if start_block != 0? Old one used to leave the things for subsequent reads to start at start_block * 512; new one will ignore that. So after > - nblocks = identify_ramdisk_image(in_fd, rd_image_start, &decompressor); > + nblocks = identify_ramdisk_image(in_file, rd_image_start, &decompressor); you'll have in_file->f_pos left at 0 instead of rd_image_start * 512. ... affecting this > - if (crd_load(in_fd, out_fd, decompressor) == 0) > + if (crd_load(in_file, out_file, decompressor) == 0) ... and this > - ksys_read(in_fd, buf, BLOCK_SIZE); > - ksys_write(out_fd, buf, BLOCK_SIZE); > + kernel_read(in_file, buf, BLOCK_SIZE, &in_file->f_pos); > + kernel_write(out_file, buf, BLOCK_SIZE, &out_file->f_pos); FWIW, I would suggest *not* bothering with ->f_pos and using two global (well, file-static, obviously) variables instead. And kill 'pos' in identify_ramdisk_image() as well - use the in_pos instead.