Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2459422pxm; Fri, 25 Feb 2022 02:19:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfEMrE90tymCTK3B+tZ0LJ0ScFdrid9tOJIvpaQwlvwuGsxK50ZTa6z0hYF2/Qa4RSQkTR X-Received: by 2002:a17:907:2bc4:b0:6cc:e4b7:dcf8 with SMTP id gv4-20020a1709072bc400b006cce4b7dcf8mr5599961ejc.596.1645784356871; Fri, 25 Feb 2022 02:19:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645784356; cv=none; d=google.com; s=arc-20160816; b=p7XE7Mpf0vfP1fJgYR2rIEmEPTeMspifxfI1HjmB0396VYmLW+xjzI5KDzLGl/Q4OQ SSAal8AycxHafQPkmVkz8WOhhKCiT2S0c1Znnn5PdQyoFq7NoGON9dhkHjT9zkTsQ2co ikrXBQ/FwNKy5E5hoLT3RaPpptkvBywVC0hZR6oqPCSg343uNqYvK1sd/kK/FN1O5Mic UrWr0itOd6YgPQ8lGRqvTm2i2qJXuiPx8/ThmaIV6/FTBL5anr+8FHgR2u00lqHxjA9p 1RzyaP5K72GwtlO80Vyzdb2jPXdvNs8YoeUqlOaSBWSm+hvB9byB9CyLuSIoWpefyphT KJeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GT8z9LqO+66soqATOFmkROoS1wym6AvUApI1SnunQHw=; b=NHrbQQUHTmEwX61aSZCmlxHYOIqs2tfIaqLtJMhkZnRZBC4O6K8WzpEwdj3vM9hnAY fT7uH35KZBR784a8XkxRra5UDtdIJsePH/1Dzz13IzXSlytZ/3QjPPbU6umD61B7nE8B 2PDdSYGx8+WQSAIODe+2dOSPSSqKylPO6VsAsNGP1rmIl9Dqk+xldrUiQg79KxA/WZ90 FBvUJZP844vpMXPV9cNdyFvekPoCkrGq/+oX25F7vxKuOgD0R/F/jcDs63207K74OCwp jZXEh97DEdm64c6iWOS80ciKdn/EkZ5Wis4Q/R9AZfCI3sJ3pC85y7rO08AGWVUR7YfG 28EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EKMYdrg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg34-20020a170907972200b0069f317757e4si1287577ejc.29.2022.02.25.02.18.53; Fri, 25 Feb 2022 02:19:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EKMYdrg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238508AbiBYI3z (ORCPT + 99 others); Fri, 25 Feb 2022 03:29:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236052AbiBYI3y (ORCPT ); Fri, 25 Feb 2022 03:29:54 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A2BFF2399C8 for ; Fri, 25 Feb 2022 00:29:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645777761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GT8z9LqO+66soqATOFmkROoS1wym6AvUApI1SnunQHw=; b=EKMYdrg3TsRL8F+pp1nqT+dO6AJj0WZ2nEBW10LxYVMZsSdYFtQHbjRcUpKi27v0MWIc2t tuoLnhklTHC2B77Z60gTevSHUomxzWOJWFiCjfX1Go8oB50xh3xoVfQQK0SCdR6nkdiJK+ CROmcRuuVupcL6D/fsnIniyGA7sXBXY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-436-b3QYUbt4NtGUkZCAWjNe0w-1; Fri, 25 Feb 2022 03:29:16 -0500 X-MC-Unique: b3QYUbt4NtGUkZCAWjNe0w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E41E9501E0; Fri, 25 Feb 2022 08:29:12 +0000 (UTC) Received: from localhost (ovpn-13-4.pek2.redhat.com [10.72.13.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 886E183172; Fri, 25 Feb 2022 08:28:42 +0000 (UTC) Date: Fri, 25 Feb 2022 16:28:39 +0800 From: Baoquan He To: Al Viro Cc: "Matthew Wilcox (Oracle)" , Vivek Goyal , Dave Young , kexec@lists.infradead.org, Tiezhu Yang , linux-kernel@vger.kernel.org, Amit Daniel Kachhap , Christoph Hellwig , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3 0/3] Convert vmcore to use an iov_iter Message-ID: References: <20211213143927.3069508-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/01/22 at 12:36am, Al Viro wrote: > On Mon, Dec 13, 2021 at 02:39:24PM +0000, Matthew Wilcox (Oracle) wrote: > > For some reason several people have been sending bad patches to fix > > compiler warnings in vmcore recently. Here's how it should be done. > > Compile-tested only on x86. As noted in the first patch, s390 should > > take this conversion a bit further, but I'm not inclined to do that > > work myself. > > A couple of notes: please, use iov_iter_count(i) instead of open-coding > i->count. And there's a preexisting nastiness in read_vmcore() - > generally, a fault halfway through the read() is treated as a short read, > rather than -EFAULT... Sorry for being late to work on this. While checking it, I noticed it's generic to return -EFAULT in kernel. E.g in kernfs_file_read_iter(). Even though 'man 3 read' does give the same words as you noted. However, the manpage says the less then nbyte case happened just in case the number of bytes left in the file is less than nbyte. The returning -EFAULT in read_vmcore() seems to be a little different and not satisfying the condition, because the left bytes should be greater than the nbyte when reading out the elf note, or the middle of the vmcore. So we should leave it as is? Abstract from man page of read: ==== Upon successful completion, where nbyte is greater than 0, read() shall mark for update the last data access timestamp of the file, and shall return the number of bytes read. This number shall never be greater than nbyte. The value returned may be less than nbyte if the number of bytes left in the file is less than nbyte, if the read() request was interrupted by a sig‐ nal, or if the file is a pipe or FIFO or special file and has fewer than nbyte bytes immediately available for reading. For example, a read() from a file associated with a terminal may return one typed line of data. ====