From owner-freebsd-bugs@freebsd.org Fri Apr 17 10:28:05 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BA1022B2A49 for ; Fri, 17 Apr 2020 10:28:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 493XNj2k6Dz4ttR for ; Fri, 17 Apr 2020 10:28:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 5D4C72B2A47; Fri, 17 Apr 2020 10:28:05 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5D0FC2B2A46 for ; Fri, 17 Apr 2020 10:28:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 493XNj1rbvz4ttQ for ; Fri, 17 Apr 2020 10:28:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A18120CF7 for ; Fri, 17 Apr 2020 10:28:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 03HAS5im083110 for ; Fri, 17 Apr 2020 10:28:05 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 03HAS5SM083109 for bugs@FreeBSD.org; Fri, 17 Apr 2020 10:28:05 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 245689] Chmod performs unnecessary access calls (FUSE fs) Date: Fri, 17 Apr 2020 10:28:05 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 12.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: freebsd@moosefs.pro X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Apr 2020 10:28:05 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D245689 Bug ID: 245689 Summary: Chmod performs unnecessary access calls (FUSE fs) Product: Base System Version: 12.1-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: freebsd@moosefs.pro FreeBSD 12.1-p2, MooseFS mounted via FUSE ver 3. We perform the following operations: $ touch test.txt ; chmod u-w test.txt ; chmod u+w test.txt chmod: test.txt: Permission denied What happens on the fs side: # touch test.txt 04.08 09:58:05.000715: uid:1001 gid:0 pid:48262 cmd:access (504599,0x1): OK 04.08 09:58:05.001324: uid:1001 gid:0 pid:48262 cmd:lookup (504599,test.txt= ): ENOENT (No such file or directory) 04.08 09:58:05.001731: uid:1001 gid:0 pid:48262 cmd:access (504599,0x1): OK 04.08 09:58:05.002157: uid:1001 gid:0 pid:48262 cmd:lookup (504599,test.txt= ): ENOENT (No such file or directory) 04.08 09:58:05.002546: uid:1001 gid:0 pid:48262 cmd:access (504599,0x2): OK 04.08 09:58:05.002946: uid:1001 gid:0 pid:48262 cmd:create (504599,test.txt,-rw-r--r--:0100644): OK (0.0,1238695,1.0,[-rw-r--r--:0100644,1,1001,0,1586332685,1586332685,1586332= 685,0]) (direct_io:0,keep_cache:0) [handle:03000001] 04.08 09:58:05.003013: uid:1001 gid:0 pid:48262 cmd:flush (1238695) [handle:03000001,uselocks:0,lock_owner:000000000000BC86]: OK 04.08 09:58:05.003249: uid:1001 gid:0 pid:48262 cmd:release (1238695) [handle:03000001,uselocks:0,lock_owner:000000000000BC86]: OK # chmod u-w test.txt 04.08 09:58:05.005207: uid:1001 gid:0 pid:48263 cmd:access (504599,0x1): OK 04.08 09:58:05.005668: uid:1001 gid:0 pid:48263 cmd:lookup (504599,test.txt= ): OK (0.0,1238695,1.0,[-rw-r--r--:0100644,1,1001,0,1586332685,1586332685,1586332= 685,0]) 04.08 09:58:05.006095: uid:1001 gid:0 pid:48263 cmd:access (504599,0x1): OK 04.08 09:58:05.006490: uid:1001 gid:0 pid:48263 cmd:lookup (504599,test.txt= ): OK (0.0,1238695,1.0,[-rw-r--r--:0100644,1,1001,0,1586332685,1586332685,1586332= 685,0]) 04.08 09:58:05.006888: uid:1001 gid:0 pid:48263 cmd:access (504599,0x1): OK 04.08 09:58:05.007260: uid:1001 gid:0 pid:48263 cmd:lookup (504599,test.txt= ): OK (0.0,1238695,1.0,[-rw-r--r--:0100644,1,1001,0,1586332685,1586332685,1586332= 685,0]) 04.08 09:58:05.007292: uid:1001 gid:0 pid:48263 cmd:access (1238695,0x2): OK 04.08 09:58:05.007903: uid:1001 gid:0 pid:48263 cmd:setattr (1238695,0x1,[mode=3Dr--r--r--:00444]) [no handle]: OK (1.0,[-r--r--r--:0100444,1,1001,0,1586332685,1586332685,1586332685,0]) # chmod u+w test.txt 04.08 09:58:05.009607: uid:1001 gid:0 pid:48264 cmd:access (504599,0x1): OK 04.08 09:58:05.009944: uid:1001 gid:0 pid:48264 cmd:lookup (504599,test.txt= ): OK (0.0,1238695,1.0,[-r--r--r--:0100444,1,1001,0,1586332685,1586332685,1586332= 685,0]) 04.08 09:58:05.010879: uid:1001 gid:0 pid:48264 cmd:access (504599,0x1): OK 04.08 09:58:05.011309: uid:1001 gid:0 pid:48264 cmd:lookup (504599,test.txt= ): OK (0.0,1238695,1.0,[-r--r--r--:0100444,1,1001,0,1586332685,1586332685,1586332= 685,0]) 04.08 09:58:05.011680: uid:1001 gid:0 pid:48264 cmd:access (504599,0x1): OK 04.08 09:58:05.012068: uid:1001 gid:0 pid:48264 cmd:lookup (504599,test.txt= ): OK (0.0,1238695,1.0,[-r--r--r--:0100444,1,1001,0,1586332685,1586332685,1586332= 685,0]) 04.08 09:58:05.012102: uid:1001 gid:0 pid:48264 cmd:access (1238695,0x2): EACCES (Permission denied) 04.08 09:58:05.596937: uid:0 gid:0 pid:48228 cmd:getattr (504599) [no handl= e]: OK (1.0,[drwxr-xr-x:0040755,3,1001,0,1586332657,1586332685,1586332685,10022= 46]) So, we have an "access" call to a file that has no "w" permission for the u= ser calling, so we get an EACCES... There are 2 problems here: 1) It is not necessary to have "w" permission to a file to change its metad= ata - this only requires the uid doing the changes to be either 0 or owner of t= he file. 2) MooseFS does NOT send "default_permissions" when initializing FUSE, so t= he whole checking of permissions should happen on the filesystem side. Yet, practically all the calls are preceded with access calls. Here is how the above chmod operations look on Linux: # chmod u-w test.txt 04.08 10:10:26.794571: uid:1000 gid:1000 pid:30550 cmd:lookup (164872,test.txt): OK (0.0,210456,1.0,[-rw-r--r--:0100644,1,1000,1000,1586326757,1586326757,15863= 26769,0]) 04.08 10:10:26.794717: uid:1000 gid:1000 pid:30550 cmd:lookup (164872,test.txt): OK (0.0,210456,1.0,[-rw-r--r--:0100644,1,1000,1000,1586326757,1586326757,15863= 26769,0]) 04.08 10:10:26.802672: uid:1000 gid:1000 pid:30550 cmd:setattr (210456,0x1,[mode=3Dr--r--r--:00444]) [no handle]: OK (1.0,[-r--r--r--:0100444,1,1000,1000,1586326757,1586326757,1586333426,0]) # chmod u+w test.txt 04.08 10:10:26.803478: uid:1000 gid:1000 pid:30551 cmd:lookup (164872,test.txt): OK (0.0,210456,1.0,[-r--r--r--:0100444,1,1000,1000,1586326757,1586326757,15863= 33426,0]) 04.08 10:10:26.803608: uid:1000 gid:1000 pid:30551 cmd:lookup (164872,test.txt): OK (0.0,210456,1.0,[-r--r--r--:0100444,1,1000,1000,1586326757,1586326757,15863= 33426,0]) 04.08 10:10:26.803790: uid:1000 gid:1000 pid:30551 cmd:setattr (210456,0x1,[mode=3Drw-r--r--:00644]) [no handle]: OK (1.0,[-rw-r--r--:0100644,1,1000,1000,1586326757,1586326757,1586333426,0]) There are no "access" calls at all. While problem 1) is a simple bug, problem 2) is a serious performance issue. MooseFS is a network filesystem and performance is very important in this c= ase - it has to receive and handle twice as many calls sent via network. --=20 You are receiving this mail because: You are the assignee for the bug.=