From owner-freebsd-current@freebsd.org Wed May 22 23:33:49 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 B2FCB1591511 for ; Wed, 22 May 2019 23:33:49 +0000 (UTC) (envelope-from johalun@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1DAC670CED; Wed, 22 May 2019 23:33:49 +0000 (UTC) (envelope-from johalun@FreeBSD.org) Received: from [10.46.14.95] (wsip-72-212-151-146.ph.ph.cox.net [72.212.151.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: johalun) by smtp.freebsd.org (Postfix) with ESMTPSA id 8999115F54; Wed, 22 May 2019 23:33:48 +0000 (UTC) (envelope-from johalun@FreeBSD.org) Subject: Re: Weirdness when writing to pseudofs file To: Alan Somers Cc: "Conrad E. Meyer" , FreeBSD Current 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> From: Johannes Lundberg X-Tagtoolbar-Keys: D20190522163347387 Message-ID: <85a70c02-49ae-e394-e7a6-9ad425250a4c@FreeBSD.org> Date: Wed, 22 May 2019 16:33:47 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Queue-Id: 1DAC670CED X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.92 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.92)[-0.916,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] 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:33:49 -0000 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..