Re: fstat vs. lseek - Mailing list pgsql-hackers

From Andres Freund
Subject Re: fstat vs. lseek
Date
Msg-id 16623238.t9h9Udve74@alap2
Whole thread Raw
In response to fstat vs. lseek  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Monday, August 08, 2011 10:30:38 Robert Haas wrote:
> In response to my blog post on lseek contention, someone posted a
> comment wherein they proposed using fstat() rather than lseek() to get
> file sizes.
> 
> Thoughts?
I don't think its a good idea to replace lseek with fstat in the long run. The 
likelihood that the lockless generic_file_llseek will get included seems rather 
high to me. In contrast to that fstat will always be more expensive than that 
as its going through a security check and then the fs' getattr implementation 
(which actually takes a lock on some fs).
On the other hand its currently lockless if the security subsystem is compiled 
out (i.e. no selinux et al) for some common fs (ext3/4, xfs).

Andres


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: fstat vs. lseek
Next
From: "Kevin Grittner"
Date:
Subject: Re: WIP fix proposal for bug #6123