From owner-freebsd-hackers@freebsd.org Sun Aug 27 14:17:19 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32618DF0DD5 for ; Sun, 27 Aug 2017 14:17:19 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BCB417328C for ; Sun, 27 Aug 2017 14:17:18 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v7REH8FS033008 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 27 Aug 2017 17:17:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v7REH8FS033008 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v7REH8jk033007 for freebsd-hackers@freebsd.org; Sun, 27 Aug 2017 17:17:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 27 Aug 2017 17:17:08 +0300 From: Konstantin Belousov To: freebsd-hackers@freebsd.org Subject: Re: [PATCH] O_NOATIME support for open(2) Message-ID: <20170827141708.GV1700@kib.kiev.ua> References: <20170826161827.GA21456@schoggimuss.roe.ch> <20170826175606.GQ1700@kib.kiev.ua> <20170827131806.GB21456@schoggimuss.roe.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170827131806.GB21456@schoggimuss.roe.ch> User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Aug 2017 14:17:19 -0000 On Sun, Aug 27, 2017 at 03:18:06PM +0200, Daniel Roethlisberger wrote: > Konstantin Belousov 2017-08-26: > > On Sat, Aug 26, 2017 at 06:18:27PM +0200, Daniel Roethlisberger wrote: > > > I'm trying to implement O_NOATIME support for open(2) in order to > > > provide a more elegant way for backup/archiving software to > > > prevent atime clobbering. Except for a 2008 thread on this list > > > I did not find any material; not sure if anybody is interested in > > > this or if there are reasons why this was never implemented. > > Please point out the thread, e.g. by providing a link to the first > > message in the thread in mailman archive. > > https://lists.freebsd.org/pipermail/freebsd-hackers/2008-October/thread.html#26531 > https://lists.freebsd.org/pipermail/freebsd-hackers/2008-October/026531.html > Thank you. > > > The attached patch against 11.1 implements O_NOATIME support for > > > open(2); it prevents read(2) and mmap(2) from clobbering atime if > > > the file descriptor was opened with O_NOATIME. O_NOATIME is only > > > permitted for root and the owner of the file. Currently it is > > > only implemented for ufs/ffs. It seems to work for me but has > > > not been extensively tested. > > What would happen when additional page-in occurs on the mmaped area ? > > With mmap, the vnode is marked for atime update at the time of > calling mmap (unless O_NOATIME is set on the fd). I do not see > how the patch would impact page-ins in any way. Can you > elaborate? I mean, do we have some code paths which would cause page-ins to set atime ? If we currently do not have that, fine. My brief reading of the code suggests that we do not, at least for UFS. Somewhat related, if an image file is opened O_EXEC | O_NOATIME, does calling fexecve(2) on the fd prevents atime update with your patch ? It seems to me that the case is not handled. Note that in kernel code, we usually prefer O_XXX spelling for the open flags over the FXXX.