Enable direct I/O with gfs2_tool

Latest response

I am working on a project where an application requires Direct I/O to be enabled on GFS.

 

For GFS version 1, there is a command to set the attribute to a specific file or path "gfs_tool setflag directio filename". 

 

On GFS2, I can't seem to find the option, I onlt see the following:

 

Flags:
  jdata
  exhash
  ea_indirect
  immutable
  appendonly
  noatime
  sync
  trunc_in_progFlags:
  jdata
  exhash
  ea_indirect
  immutable
  appendonly
  noatime
  sync
  trunc_in_prog

Flags:

  jdata

  exhash

  ea_indirect

  immutable

  appendonly

  noatime

  sync

  trunc_in_prog

 

Does anyone know what the equivalent is in GFS2?

Responses

 

There is no need to "turn on" direct i/o support before use, either in GFS or GFS2. In both cases you can just open the file using the O_DIRECT flag and it will work just like most other Linux filesystems.

 

Also, it is worth noting that writes which result in block allocation will be (internally, and transparently) changed into buffered i/o writes. So that to make best use of O_DIRECT with GFS/GFS2 ideally a preallocated file would be used. This is the same as with ext3.

 

The gfs_tool setflag option for directio does something slightly different. It was introduced to allow use of direct i/o with applications which do not support it by converting normal i/o requests into direct i/o requests. However, applications which were not written for direct i/o, do not in general align their i/o buffers as required by direct i/o. This means that this option will not work in those cases. For that reason this option is considered obsolete and is no longer supported in GFS2.