Cifs: dara corruption fix for cache=none when reading a mmapped file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steve, List,
This issue is similar to kernel bugzilla 216301 but is the opposite case.
For cache=none, before we perform a pread() we have to destage any dirty
pages back to the server before we allow the pread() to be performed.


A simple test application for this:
===================================
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>


void write_x_1(int fd, int offset) {
        char b[] = {"x"};
        printf("Writing 'x' at offset: %d. Result: %d\n", offset, pwrite(fd, &b\
, 1, offset));
}


int main(int argc, char *argv[]){
        char buf[32] = {};
        int fd = open(argv[1], O_RDWR|O_CREAT, 0600);
        printf("File descriptor: %d\n", fd);
        char *m = mmap(NULL, 30, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE,\
 fd, 0);
        printf("Madvised: %d\n", madvise(m, 30, MADV_RANDOM));
        printf("1. Reading file content after mmaping: \n%s\n", m);
        write_x_1(fd, 4);
        write_x_1(fd, 9);
        write_x_1(fd, 14);
        write_x_1(fd, 19);
        write_x_1(fd, 24);

        printf("\n");
        printf("2. After updating file content: \n%s\n", m);

        m[5] = 'a';
        m[10] = 'a';
        m[15] = 'a';
        printf("\n");
        pread(fd, buf, 32, 0);
        printf("3. After updating file content: \n%s\n", buf);


        munmap(m, 30);
        close(fd);
}








[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux