From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Vadim Mikheev <vadim4o(at)email(dot)com> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Is XLogFileInit() hoping to force space allocation? |
Date: | 2000-11-27 05:48:21 |
Message-ID: | 6798.975304101@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I'm wondering about the intent of this snippet in xlog.c:
fd = BasicOpenFile(tpath, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0)
elog(STOP, "InitCreate(logfile %u seg %u) failed: %m",
logId, logSeg);
if (lseek(fd, XLogSegSize - 1, SEEK_SET) != (off_t) (XLogSegSize - 1))
elog(STOP, "lseek(logfile %u seg %u) failed: %m",
logId, logSeg);
if (write(fd, "", 1) != 1)
elog(STOP, "write(logfile %u seg %u) failed: %m",
logId, logSeg);
if (fsync(fd) != 0)
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
logId, logSeg);
if (lseek(fd, 0, SEEK_SET) < 0)
elog(STOP, "lseek(logfile %u seg %u off %u) failed: %m",
log, seg, 0);
close(fd);
If the idea here is to force XLogSegSize bytes of disk space to be
allocated, it's a loser. Most Unix file systems that I know about
will treat the file as containing a "hole", and only allocate the
single block in which data has actually been written. The fact
that 'ls' shows the file as 16MB is a user-interface artifact of ls;
du will tell you the grim truth:
$ initdb
...
$ ls -l data/pg_xlog
total 328
-rw------- 1 postgres users 16777216 Nov 27 00:44 0000000000000000
$ du data/pg_xlog/0000000000000000
328 data/pg_xlog/0000000000000000
I don't know whether you consider it important to force the logfile
to be fully allocated before you start using it; but if you do,
the above code will not get the job done.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Chmara | 2000-11-27 07:38:46 | Re: Re: [NOVICE] Re: re : PHP and persistent connections |
Previous Message | Tom Lane | 2000-11-27 05:32:58 | Re: Initdb not running on beos |