• Trond Myklebust's avatar
    [PATCH] Fix spurious ETXTBSY errors due to late release of struct file · b67b3c16
    Trond Myklebust authored
      The following patch should fix a problem of ETXTBSY sometimes
    occurring if one tries to run a file straight after compilation.
    
    The problem is that both NFS read and write requests can currently
    hold a count on the struct file. This is done partly so as to be able
    to pass along the RPC credential (which is cached in the struct file),
    and partly so that asynchronous writes can report any errors via the
    file->f_error mechanism.
    
    The problem is that both the read and write requests may persist even
    after file close() occurs. For O_RDONLY files, this is not a problem,
    but for O_WRONLY, and O_RDWR files, the fact that the struct file is
    not released until the last call to nfs_release_request() means that
    inode->i_writecount does not necessarily get cleared upon file
    close().
    
    The following patch fixes both these issues.
    
      - NFS read requests no longer hold the struct file. They take a
        count on the the RPC credential itself.
    
      - NFS write requests still hold the struct file, since they want to
        report errors to sys_close() using the file->f_error mechanism.
        However they are made to release the page, credential, and file
        structures as soon as the write is completed instead of following
        the current practice of waiting for the last nfs_page request
        release.
    b67b3c16
read.c 12.7 KB