Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp719150pxb; Mon, 25 Oct 2021 17:22:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhXbnbZehwtMzupbbotRX6jtzcrcJy8vhP51RB0u+6Ntz2fO7iHiSH90QRAgMZWBCskjUC X-Received: by 2002:a17:903:120c:b0:13f:d043:3477 with SMTP id l12-20020a170903120c00b0013fd0433477mr19387351plh.89.1635207775427; Mon, 25 Oct 2021 17:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635207775; cv=none; d=google.com; s=arc-20160816; b=D6Tj3+NaHOvM7bDfCGg76hqVTur5KxYck+LU1XCv+IIA3Erc16QA8eM3MzEZKsUVMJ lYEcqoTdfLaECi5VZkaLyqFfm+1fyqcgIG8C4XaCGeU7Ft1eYJffsq9ZfnUuOml5DShX RsNfJpwSIQTnDV8e7cJq74sghLossh2ibDFPQirHfGzfhbzUBbC6imVu2G7Tm4xvI8rC zaojVNA/Upn90xFYjnU5J8TqNPbKh4gKfWAK5b4ZkZfawOcuJ2+b71KDjDMBGc+stI2u bhlsaFKWZF1Jysk7BLePdN3wdwWcgTpmynAMTYdDkxOXIbZFdr1jY8Ci8BbKTyOGFDNb yh4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9aAky+o+A3o8orvEWSZgWo8dAX6pVohf78faelvH+XE=; b=ppfzfiSvCXZoRr5m+zLKC2temt5EzJKqPjO3Ok2XEhstk58EkIwQubjh9OmMUfRhP9 wsGYDNle060nTSkJp2fUPIT3QKhnMQfnWKFIF2OJrLKyJoDzfxt5MRQlG04LM6mJ36bP mGJivOuUePHLld+HbkyB2GlI7r0VOdgaHVdAUFNXhWmfLdNNmBUVp34ziKLLNPCSMbmo 5q584uAadCEmtigqdlFrGfPTtjanl6WuTzGPkQighP4C5Q97v3F++mDPG/R3VY0ippUz 7LRzqdHa9FoPzKR/xGjNmxg+Dv4pB7TvNGBlNV0An3v+vtsxdE95stB4+TvPXmqSmdgy zKWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GnGMcLhE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si28870111pgw.185.2021.10.25.17.22.42; Mon, 25 Oct 2021 17:22:55 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GnGMcLhE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236554AbhJYTr0 (ORCPT + 99 others); Mon, 25 Oct 2021 15:47:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23957 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237190AbhJYTj7 (ORCPT ); Mon, 25 Oct 2021 15:39:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635190656; 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: in-reply-to:in-reply-to:references:references; bh=9aAky+o+A3o8orvEWSZgWo8dAX6pVohf78faelvH+XE=; b=GnGMcLhE+usm1Nj2t2QZPQorJZ+Y/fs9IM0frnSNf8eHWuOAyialCV9EqU1CvjVe+GJMlP k6UBzcNeO2OF0NYXX/mIMDJ/JUB+5AH/BA7P/zhBpXuvyyXRnYpJyYEtgxbYI8BHb2TTLI MzXtSKiymcD/F4GRz/1L9PNJooI9zmY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-Fhla3MdgP4-KjUBP7db6Ag-1; Mon, 25 Oct 2021 15:37:34 -0400 X-MC-Unique: Fhla3MdgP4-KjUBP7db6Ag-1 Received: by mail-wm1-f70.google.com with SMTP id k6-20020a7bc306000000b0030d92a6bdc7so397333wmj.3 for ; Mon, 25 Oct 2021 12:37:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9aAky+o+A3o8orvEWSZgWo8dAX6pVohf78faelvH+XE=; b=FNDgfgYMJsk5xaRcbHQcsH7x51IyZewG9jd38TPQMjQG2R4FyGj42eiYXEUPKjQw9l OYMqkSoe7xMBRvY40FRIgzTzo/o3AbZaaHVDL4Uq8nvcXABwS2NHCYz2Upk+nK7b3qnj nj0EjOZatGrlQnuXBwrexnm4znr/a3tNVBXyZ8AvrbFZkLwwePbg/U7HW6msi809pAWZ SQTBXHGuWTdhSpu9QBjAUOnqZ0Rjv9m3MKJwUFR1qI/NzAOIOpZqvtApaLZT2VyPQ/Oj IPHGZidESKX9/3vymEZvwFYhU9qt6K6YRUcu3Uk09BACrO/GH3pC63NMQ9LA3u3C2Hi+ 9A4A== X-Gm-Message-State: AOAM530G9SPf+2WRs6sj1cSb3BTEExaswGsc4OzoeHIfglRXWXrtntoB IB9k3EpFh4GF0oTgO6AiQ+J6/9f8Ud3YAokExg2ImnF0ZoCrAImzUQMmeJAy3Dr58kWNCLYkn6k ZDn7JwYC0l/ZSTK4Bh16ZXShP88qlKhIhv3bDjpA8 X-Received: by 2002:adf:e411:: with SMTP id g17mr24943047wrm.228.1635190653767; Mon, 25 Oct 2021 12:37:33 -0700 (PDT) X-Received: by 2002:adf:e411:: with SMTP id g17mr24943016wrm.228.1635190653583; Mon, 25 Oct 2021 12:37:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andreas Gruenbacher Date: Mon, 25 Oct 2021 21:37:22 +0200 Message-ID: Subject: Re: [RFC][arm64] possible infinite loop in btrfs search_ioctl() To: Catalin Marinas Cc: Linus Torvalds , Al Viro , Christoph Hellwig , "Darrick J. Wong" , Jan Kara , Matthew Wilcox , cluster-devel , linux-fsdevel , Linux Kernel Mailing List , "ocfs2-devel@oss.oracle.com" , Josef Bacik , Will Deacon Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 22, 2021 at 8:41 PM Catalin Marinas wrote: > On Thu, Oct 21, 2021 at 08:00:50PM +0200, Andreas Gruenbacher wrote: > > On Thu, Oct 21, 2021 at 7:09 PM Catalin Marinas wrote: > > > This discussion started with the btrfs search_ioctl() where, even if > > > some bytes were written in copy_to_sk(), it always restarts from an > > > earlier position, reattempting to write the same bytes. Since > > > copy_to_sk() doesn't guarantee forward progress even if some bytes are > > > writable, Linus' suggestion was for fault_in_writable() to probe the > > > whole range. I consider this overkill since btrfs is the only one that > > > needs probing every 16 bytes. The other cases like the new > > > fault_in_safe_writeable() can be fixed by probing the first byte only > > > followed by gup. > > > > Hmm. Direct I/O request sizes are multiples of the underlying device > > block size, so we'll also get stuck there if fault-in won't give us a > > full block. This is getting pretty ugly. So scratch that idea; let's > > stick with probing the whole range. > > Ah, I wasn't aware of this. I got lost in the call trees but I noticed > __iomap_dio_rw() does an iov_iter_revert() only if direction is READ. Is > this the case for writes as well? It's the EOF case, so it only applies to reads: /* * We only report that we've read data up to i_size. * Revert iter to a state corresponding to that as some callers (such * as the splice code) rely on it. */ if (iov_iter_rw(iter) == READ && iomi.pos >= dio->i_size) iov_iter_revert(iter, iomi.pos - dio->i_size); Andreas