Desativar cache de arquivos para o ponto de montagem

3

Eu encontrei um bug semelhante a este:

O cliente RHEL NFS retorna bytes NULL ao ler um arquivo crescente

Então, minha solução foi verificar \ 0 Bytes e reler o arquivo. O problema aqui é que o arquivo incorreto, que inclui o \ 0 Bytes, é armazenado em cache no sistema em que o aplicativo java é executado. Por isso, demora um pouco para ler o conteúdo correto do arquivo.

Quando faço um sync && echo 2 > /proc/sys/vm/drop_caches , ele lê imediatamente o conteúdo correto.

Eu tentei adicionar sync às opções de montagem do NFS sem diferença.

É possível desativar o cache de arquivos para um ponto de montagem específico? Se sim, como fazer isso?

    
por robin.koch 20.07.2015 / 13:50

1 resposta

1

Resolution

This issue was discussed with Red Hat Engineering under Private Bug 702085, but was not able to be repaired within the RHEL 5 product lifecycle.

Red Hat Product Management have elected not to repair this issue within RHEL 6 for the following reasons:

  • Customer exposure to this issue is not significant.
  • This behaviour is documented on the Customer Portal along with workarounds.
  • This behaviour is much harder (takes longer) to reproduce in RHEL 6 compared to RHEL 5.
  • The NFS protocol does not guarantee cache coherence.

Workarounds:

  • Ensure one client cannot read a file while another client is accessing it by using file locks, such as flock in shell scripts, or fcntl() in C.
  • Open the file with O_DIRECT so that the page cache is avoided.
  • Do not read past the EOF.
  • For example, in Python use os.stat() to get the file size, os.open() to open the file and os.read() to read only up to the file size.
  • Avoid running tail -f on files residing on NFS mounts.
  • If using RHEL 5, the sync mount option will also avoid this issue. This will not work in RHEL6, as the nfs_readpage_sync() function was removed upstream in between RHEL 5 and RHEL 6, so that function does not exist in RHEL 6.
    
por 25.08.2015 / 18:00