From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-f50.google.com ([209.85.210.50]:46635 "EHLO mail-ot1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727010AbeIQNFl (ORCPT ); Mon, 17 Sep 2018 09:05:41 -0400 Received: by mail-ot1-f50.google.com with SMTP id v44-v6so10301188ote.13 for ; Mon, 17 Sep 2018 00:39:30 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <648A0C2F-7AB6-43D5-82DB-747B1C0E0F16@xaker.ru> References: <5c7118c8-7504-6f6a-1402-9c9c02c2f2c7@xaker.ru> <648A0C2F-7AB6-43D5-82DB-747B1C0E0F16@xaker.ru> From: Miklos Szeredi Date: Mon, 17 Sep 2018 09:39:29 +0200 Message-ID: Subject: Re: FUSE: write() after release() To: Oleg Chernovskiy Cc: linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Sep 17, 2018 at 9:24 AM, Oleg Chernovskiy wrote: > The problem is, I initially tried implementing fs thinking that release call > is executed if there are no open instances of file. > > Isn't that the case for non-fuse filesystems? There's some amount of confusion here because of the way file handles can be duplicated on UNIX (e.g. by dup() or fork(), etc). So remember the difference between file descriptor (which references an open file) and the open file itself. 1) If you call open(2) twice on the same path, you'll get two open files, and hence you'll get two releases when the files are closed. 2) If you call open(2) once, then dup(), and then close the first fd, you'll *not* get a release (only a flush, which is called on every close(2)). When you close the second file descriptor, only then you'll get the release. I think this is documented pretty well in the fuse header files. Thanks, Miklos