After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 566064 - Add NOATIME flag to query_info_flags
Add NOATIME flag to query_info_flags
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.19.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2008-12-30 17:00 UTC by A. Walton
Modified: 2009-01-05 16:21 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
adds noatime (1.86 KB, patch)
2008-12-30 17:01 UTC, A. Walton
none Details | Review
as suggested (1.72 KB, patch)
2009-01-02 05:23 UTC, A. Walton
none Details | Review
third times a charm? (1.71 KB, patch)
2009-01-05 07:03 UTC, A. Walton
none Details | Review

Description A. Walton 2008-12-30 17:00:14 UTC
Indexers like Tracker would like to use the O_NOATIME flag on Linux to prevent lots of spurious updates to the file system. (Pointed out here http://mail.gnome.org/archives/tracker-list/2008-December/msg00146.html).

Patch introducing the new flag and implementing it in GLocalFile follows.
Comment 1 A. Walton 2008-12-30 17:01:01 UTC
Created attachment 125536 [details] [review]
adds noatime
Comment 2 Matthias Clasen 2009-01-02 03:13:31 UTC
The general idea makes sense to me.

Some comments on the implementation:

+#ifndef O_NOATIME
+#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
+#define O_NOATIME 01000000
+#else
+#define O_NOATIME 0
+#endif
+#endif

I don't think we should do hackery like this. Instead, define 
_GNU_SOURCE before including fcntl.h.

Also, man open mentions only EPERM as something that may be affected by O_NOATIME, so I think open_noatime should maybe look more like this:

static int
open_noatime (const char          *path, 
              GFileQueryInfoFlags  flags)
{
  int fd;

#ifdef O_NOATIME
  errno = 0;
  if (flags & G_FILE_QUERY_INFO_NOATIME)
    fd = open (path, O_RDONLY | O_NOATIME);
  if (errno == EPERM)
#endif
    fd = open (path, O_RDONLY);

  return fd;
}
Comment 3 A. Walton 2009-01-02 05:23:19 UTC
Created attachment 125615 [details] [review]
as suggested

Sounds good to me. I was following git's example, so understandably might not have been the best idea for libraries. *g*
Comment 4 Dan Winship 2009-01-02 21:20:37 UTC
is there any need to bash errno? can't you just do "if (fd == -1 && errno == EPERM)" ?
Comment 5 A. Walton 2009-01-05 07:03:13 UTC
Created attachment 125769 [details] [review]
third times a charm?
Comment 6 Matthias Clasen 2009-01-05 14:32:53 UTC
Actually, I talked to alex about this, and we think we should just unconditionally try noatime for mime sniffing, so there's no need 
for a new query flag.
Comment 7 Matthias Clasen 2009-01-05 16:21:03 UTC
2009-01-05  Matthias Clasen <mclasen@redhat.com>

        Bug 566064 – Add NOATIME flag to query_info_flags

        * glocalfileinfo.c (get_content_type): Try using O_NOATIME when
        sniffing for mime types. Based on a patch by A. Walton