filesetup: make trim jobs respect --readonly during file open
authorVincent Fu <vincent.fu@wdc.com>
Fri, 15 Jun 2018 21:05:28 +0000 (15:05 -0600)
committerVincent Fu <vincent.fu@wdc.com>
Mon, 18 Jun 2018 17:10:26 +0000 (11:10 -0600)
Open files for trim workloads with the O_RDWR access mode only when
the --readonly option is absent.

filesetup.c

index 75694bd81825082516d9f1601de08a650ebe9aa1..a2427a1a80bb0bea52aeee2cab761faac09a5cef 100644 (file)
@@ -674,7 +674,8 @@ open_again:
                        from_hash = file_lookup_open(f, flags);
        } else if (td_trim(td)) {
                assert(!td_rw(td)); /* should have matched above */
-               flags |= O_RDWR;
+               if (!read_only)
+                       flags |= O_RDWR;
                from_hash = file_lookup_open(f, flags);
        }