Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp700728ybg; Sun, 26 Jul 2020 18:53:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNAE686NDKn7jpiYZZYDcJEx8nojnpFNnHsnj0y6TIfGJ9zn4TxJYujYel0QlgRrP1OfRR X-Received: by 2002:a17:906:f290:: with SMTP id gu16mr7437894ejb.502.1595814806751; Sun, 26 Jul 2020 18:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595814806; cv=none; d=google.com; s=arc-20160816; b=TA07kT3iJP2SFpOhNvLa39uBOE4RWYQuYWcY7VlFe8LpfQ8ZENfNGROSUAcrCtun24 yJLzU69ihFgHVOllp6/Jyr7GMz6GTxC2IOjUIAq3dXupcP6jvEEFTBP3eissL7BtJzS6 FicOEixHTJhv6vL5Y9oc1R9Qa5MkWGhLzBBbfJ/OfCbgoL7lBDE8nRb8qGz5dFQUKdnU UR34/Vw4FuyGh7OUnyJ8a2o1lRVIPphy7N+gUTa6EpJqApALsVxR4kxxtTqgPUjaG6xY mV68BlcDM1FmcKQHVB3khcqYIlYzisObhPc4PAZS+BNwwG7H26kyEKFOIwrOTmU6BHOB +DjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=oriciRuPiZsy0ySzyG6ygMEdH5CYTdQzALvsjChaL6w=; b=evjB11meAPsKGdAKmerTc7B79O7kRt15BL/8cK3VQ4m3gK8AhSkBAB1vqTM39UdstC hXO/gjgSgx5XEYd4L4Eo7UacQbZXRb0b1nadjqgfPMat5jA8KEfUsnk1lM7H98ReEP6/ Dx7NIwvANHDCo8X7oYZog16R0oUsuTtKEZ5r6/iBszBV6B/DfnUax+Q0c0OdkhMUiuVz zrhLsbMS41mIvadirg7tprbvB3bRD57Z9viXQsygh8+p4lpLNme3OgcC8fCDf4Sp7UT8 8dNJB79USNPMyrY3m3f2yPi9zK2a1L+7GCIDHVlWzAD64y817akdfAHpgWehqoK6/Xph zeDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n3si4514001edv.602.2020.07.26.18.53.05; Sun, 26 Jul 2020 18:53:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbgG0Buo (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.