Project

General

Profile

Actions

Bug #7420

closed

posix_fallocate failed under CentOS 6.5 when DIO enabled

Added by Haomai Wang about 10 years ago. Updated about 9 years ago.

Status:
Won't Fix
Priority:
Normal
Assignee:
-
Category:
OSD
Target version:
-
% Done:

0%

Source:
other
Tags:
Backport:
Regression:
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

under CentOS 6.5, when enable DIO and initialize OSD directory will cause failed:

2014-02-14 05:46:15.591387 7ffff7fe9760 -1 filestore(store_test_temp_dir) mount failed to open journal store_test_temp_journal: (22) Invalid argument

FileJournal open journal with O_DIRECT flag and call posix_fallocate next. The return value will be 22. From implementation of posix_fallocate, it will read 1 byte per block:

  for (offset += (len - 1) % f.f_bsize; len > 0; offset += f.f_bsize)
    {
      len -= f.f_bsize;

      if (offset < st.st_size)
    {
      unsigned char c;
      ssize_t rsize = __pread (fd, &c, 1, offset);

      if (rsize < 0)
        return errno;
      /* If there is a non-zero byte, the block must have been
         allocated already.  */
      else if (rsize == 1 && c != 0)
        continue;
    }


Then __pread return 22.

In order to verify, I write a simple program to test under CentOS 6.5:


#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>

int main()
{
    uint64_t d = 400<<20;
    int r;
    int fd = open("dd.tmp", O_CREAT|O_RDWR|O_DIRECT|O_DSYNC, 0644);
    printf("%ld\n", d);
    printf("%d\n", fd);
    r = ::ftruncate(fd, d);
    printf("%d\n", r);
    r = ::posix_fallocate(fd, 0, d);
    printf("%d\n", r);
    close(fd);
    return 0;
}

The result confirm my assumption.


# ./dd
419430400
3
0
22
Actions #1

Updated by Haomai Wang about 10 years ago

posix_allocate in FileJournal::_open_file will call pread to pre-allocate space which will return 22 because unalgined buffer to store if DIO enabled

http://man7.org/linux/man-pages/man2/read.2.html

Actions #2

Updated by Samuel Just about 9 years ago

  • Status changed from New to Won't Fix
Actions #3

Updated by Sage Weil about 9 years ago

not sure what we should differently here.. fallocate either works or it doesn't

Actions

Also available in: Atom PDF