From owner-freebsd-current@freebsd.org Wed May 22 23:57:28 2019 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9178E1591E4D for ; Wed, 22 May 2019 23:57:28 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) 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 94D1371605; Wed, 22 May 2019 23:57:27 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lj1-f177.google.com with SMTP id z5so3699004lji.10; Wed, 22 May 2019 16:57:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RRNrKiF1XEp9m4Ir+ORTRmMUT5eony4Kz9HSK4s0Ay0=; b=AGS/UbDMdzEXQilwLIn7MgIqTchxuxsiilJy7fnlTJxYLngJnOUZNNW3V+ai3hkQis IIAi37PuoMY8ltflTSrpnY7btde9b7WBb1igqBn+GC+XqKFSciDNi4PQ8NUHUoSy7RPj nWZFE+ZYpp9sPJWOC4nIP46Htme920a+EK02eBsOm7cfGvi9rLN2vT4UKjA2G5J0sxeY /0IHEUWZjuiE9BiHlU9zG713BClPXuv0FyxrzxMMA8Bc/IhH9t8kSfbPV/9dAJ4xmzbb wA1dV2Haxd3IrQkNoxQjEQ0NKrHK3Ptv47icAFV4NtzTJldVXyRq244PGLUMb4iaOXnT BRoQ== X-Gm-Message-State: APjAAAUC/ZqTvJlFtPupU5T9GeeW19M4vesbHwhAcbEv7aG8MmRmPOYG wmUuAKYbHPD6nSpKiFsNhVMoMXAB+DrTTEU/MTms8g== X-Google-Smtp-Source: APXvYqzzQ4kb5BPmFldXi2qk4jJysq7ytLFRs6An1OwYNN/cKvTpctPUVOgA34UwWLFfITTZZmXQY0FPXyyxaHbxux8= X-Received: by 2002:a2e:418:: with SMTP id 24mr987255lje.156.1558569445391; Wed, 22 May 2019 16:57:25 -0700 (PDT) MIME-Version: 1.0 References: <6ec62e4d-9f93-ffe1-646c-3846c9308334@FreeBSD.org> <20190522175133.GC2748@kib.kiev.ua> <84e3001b-646d-b1d9-f206-577d63f79bf1@FreeBSD.org> <917d2e91-3337-bb29-0103-d6319096a95f@FreeBSD.org> <9dfca165-0cb3-e183-285e-fb41c4870d72@FreeBSD.org> <85a70c02-49ae-e394-e7a6-9ad425250a4c@FreeBSD.org> In-Reply-To: <85a70c02-49ae-e394-e7a6-9ad425250a4c@FreeBSD.org> From: Alan Somers Date: Wed, 22 May 2019 17:57:13 -0600 Message-ID: Subject: Re: Weirdness when writing to pseudofs file To: Johannes Lundberg Cc: "Conrad E. Meyer" , FreeBSD Current Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 94D1371605 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.208.177 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-4.22 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_TLS_LAST(0.00)[]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; NEURAL_HAM_SHORT(-0.93)[-0.925,0]; RCVD_IN_DNSWL_NONE(0.00)[177.208.85.209.list.dnswl.org : 127.0.5.0]; IP_SCORE(-1.28)[ip: (-0.63), ipnet: 209.85.128.0/17(-3.45), asn: 15169(-2.28), country: US(-0.06)]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2019 23:57:28 -0000 On Wed, May 22, 2019 at 5:33 PM Johannes Lundberg wrote: > > > On 5/22/19 4:22 PM, Alan Somers wrote: > > On Wed, May 22, 2019 at 5:18 PM Johannes Lundberg wrote: > >> > >> On 5/22/19 4:12 PM, Johannes Lundberg wrote: > >>> On 5/22/19 3:02 PM, Conrad Meyer wrote: > >>>> On Wed, May 22, 2019 at 1:58 PM Johannes Lundberg wrote: > >>>>>> It seems, a single '>' will cause it to try to create the file (even > >>>>>> though it already exists) and that fails (kern_openat). > >>>>>> > >>>>> I would guess because of > >>>>> > >>>>> https://github.com/freebsd/freebsd/blob/master/sys/fs/pseudofs/pseudofs_vnops.c#L1042 > >>>>> > >>>>> struct vop_vector pfs_vnodeops = { > >>>>> ... > >>>>> .vop_create = VOP_EOPNOTSUPP, > >>>>> ... > >>>>> } > >>>> kern_openat -> vn_open(_cred) should only call VOP_CREATE if namei() > >>>> cannot find the named vnode (ni_vp == NULL). Otherwise, it should > >>>> just invoke VOP_OPEN. This suggests there might be a lookup bug in > >>>> pfs? Tracing VOPs as Mark suggested seems like a good next step. > >>>> > >>>> Best, > >>>> Conrad > >>> Thanks Conrad. Yeah, that makes sense that it would open instead of > >>> recreating. Tracing a'la Mark points to > >>> > >>> vop_getwritemount > >>> > >>> failing. > >> Actually vop_setattr also shows up in dtrace. > >> > >> I'll continue digging.. > > vop_setattr would get called to truncate the file's size down to 0. > > That's probably called by sh which is opening the file with O_TRUNC. > > > > -Alan > > It works if I simply return 0 from pfs_setattr so that's the culprit > indeed. Hmm, wonder if there's any elegant solution to this.. I think it would be legal to return 0 and ignore unchangeable attributes. After all, you aren't aiming for a full POSIX-compliant file system here. -Alan