From nobody Thu Sep 30 21:11:02 2021 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D93BE17DF7ED for ; Thu, 30 Sep 2021 21:11:15 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HL5Wk4HJNz4sFp for ; Thu, 30 Sep 2021 21:11:14 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-ot1-f54.google.com with SMTP id x33-20020a9d37a4000000b0054733a85462so8999768otb.10 for ; Thu, 30 Sep 2021 14:11:14 -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:from:date:message-id:subject:to; bh=vmi1mhRmt1Mab08jZ/FpUt0srQ85iAJ6ssg4UQbpXLU=; b=SxffaNsPzxpdqTGDTMBNA6mQ4W/2EhS24m49RJBA475N6uGZfTNgxYGDqO/Nx+S8sh 6Ak8WykLgom7PSCKf0tEXJIwXE4gcuiw2MmguG5lhrn4cZRXbhpRpupkfmMrSUk8rzdn acoBshf3qa8WAJLGZF1VnCPnvoL3T/rOgm4599EBASlxUT5YdI1We1f/EJ673+vew4qN YoCo1oaFiBV3omoXCqYpm1GghpcrQ2h2FMdthCbgNduZPNV8Q6EzpGPtFlcKTcG7tgvH iTWsqRFCvevqJpQR7iE/3DUCyaHQneTXlaC4q9PWcQNKq1ss9PbSWV9sozWlyjmkvVwI b/qg== X-Gm-Message-State: AOAM533a2XYj1DsrrUa82Uil+ublhHUaabtenrlQ9ZQNfNxB9m7otegq xyobh8Se9sHV356xTFPNeqrQf7lXPPlllKC9dU8S+vM2A5c= X-Google-Smtp-Source: ABdhPJwgfsy8Y0nDQLIrJPHKeDcMG9RM7kGpIjpC0ICHngRrIwQhMf4we7vEiIfZwC0xFfvWGJcAiVsMB3JBokIBvBg= X-Received: by 2002:a05:6830:2783:: with SMTP id x3mr7067940otu.371.1633036273449; Thu, 30 Sep 2021 14:11:13 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 From: Alan Somers Date: Thu, 30 Sep 2021 15:11:02 -0600 Message-ID: Subject: livelock in vfs_bio_getpages with vn_io_fault_uiomove To: FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4HL5Wk4HJNz4sFp X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.210.54 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-2.93 / 15.00]; RCVD_TLS_ALL(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FREEFALL_USER(0.00)[asomers]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[209.85.210.54:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; DMARC_NA(0.00)[freebsd.org]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.93)[-0.932]; RCVD_IN_DNSWL_NONE(0.00)[209.85.210.54:from]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; TO_DOM_EQ_FROM_DOM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N I'm trying to adapt fusefs to use vn_io_fault_uiomove to fix the deadlock described in the comments above vn_io_fault_doio [^1]. I can reproduce the deadlock readily enough, and the fix seems simple enough in other filesystems [^2][^3]. But when I try to apply the same fix to fusefs, the deadlock changes into a livelock. vfs_bio_getpages loops infinitely because it reaches the "redo = true" state. But on looping, it never attempts to read from fusefs again. Instead, breadn_flags returns 0 without ever calling bufstrategy, from which I infer that getblkx returned a block with B_CACHE set. Despite that, at least one of the requested pages in vfs_bio_getpages fails the vm_page_all_valid(ma[i]) check. Debugging further is wandering outside my areas of expertise. Could somebody please give me a tip? What is supposed to mark those pages as valid? Are there any other undocumented conditions needed to use vn_io_fault_uiomove that msdosfs and nfscl just happened to already meet? Grateful for any help, -Alan [^1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238340 [^2] https://github.com/freebsd/freebsd-src/commit/2aa3944510b50cbe6999344985a5a9c3208063b2 [^3] https://github.com/freebsd/freebsd-src/commit/ddfc47fdc98460b757c6d1dbe4562a0a339f228b