> -----Original Message----- > From: Linux-nvdimm [mailto:linux-nvdimm-boun...@lists.01.org] On > Behalf Of Vishal Verma > Sent: Thursday, November 10, 2016 3:56 PM > To: Dan Williams <dan.j.willi...@intel.com> > Cc: linux-nvdimm@lists.01.org > Subject: Re: [PATCH v2] libnvdimm: check and clear poison before > writing to pmem > ... > > > > This feels like over-engineering a still not perfect solution to a > > rare problem. Outside of atomic-write-and-clear we should just keep > > the code best effort and simple. > > Fair enough :) In that case I think the only change needed is to simply > remove the cleared != size check, do badblocks_clear for "cleared >> 9" > (as it is now), and then write "size", and return success. Sound good?
Writing size is dangerous. The CPU might not have big enough write instructions to avoid causing reads and trigger more uncorrectable errors. Plus, if the function supports size being less than the number of bytes covered by ECC (e.g. 8 bytes), then a read modify write must be done. If those 8 bytes currently hold an ECC error, then this write must not fix that error and silently upgrade an error into bogus good data. But, preserving the error would mean the bytes written (and just declared good) are immediately bad again. Writing cleared is unnecessary, since the caller is only told that this write function failed, not that it failed after writing a certain number of bytes. This still needs to happen after badblocks_clear (or after the memcpy_to_pmem and nvdimm_flush, if I haven't convinced you to skip those steps): >> + if (cleared != size) >> + return -EIO; --- Robert Elliott, HPE Persistent Memory _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm