Message ID | 20190122024810.4448-1-richardw.yang@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] libnvdimm, pfn: use size is enough | expand |
On Mon, Jan 21, 2019 at 6:49 PM Wei Yang <richardw.yang@linux.intel.com> wrote: > > When trying to see whether current nd_region intersects with others, we > have already calculated the *size* to be expanded to SECTION size. > > So just pass size is enough. > > Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> > --- > drivers/nvdimm/pfn_devs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c > index becf0bb481b3..5eca050b3660 100644 > --- a/drivers/nvdimm/pfn_devs.c > +++ b/drivers/nvdimm/pfn_devs.c > @@ -686,7 +686,7 @@ static void trim_pfn_device(struct nd_pfn *nd_pfn, u32 *start_pad, u32 *end_trun > if (region_intersects(start, size, IORESOURCE_SYSTEM_RAM, > IORES_DESC_NONE) == REGION_MIXED > || !IS_ALIGNED(end, nd_pfn->align) > - || nd_region_conflict(nd_region, start, size + adjust)) > + || nd_region_conflict(nd_region, start, size)) Good catch, thanks. I fixed up the changelog a bit and applied this: libnvdimm, pfn: Fix over-trim in trim_pfn_device() When trying to see whether current nd_region intersects with others, trim_pfn_device() has already calculated the *size* to be expanded to SECTION size. Do not double append 'adjust' to 'size' when calculating whether the end of a region collides with the next pmem region. Fixes: ae86cbfef381 "libnvdimm, pfn: Pad pfn namespaces relative to other regions" Cc: <stable@vger.kernel.org> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
On Tue, Jan 22, 2019 at 05:28:39PM -0800, Dan Williams wrote: >On Mon, Jan 21, 2019 at 6:49 PM Wei Yang <richardw.yang@linux.intel.com> wrote: >> >> When trying to see whether current nd_region intersects with others, we >> have already calculated the *size* to be expanded to SECTION size. >> >> So just pass size is enough. >> >> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> >> --- >> drivers/nvdimm/pfn_devs.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c >> index becf0bb481b3..5eca050b3660 100644 >> --- a/drivers/nvdimm/pfn_devs.c >> +++ b/drivers/nvdimm/pfn_devs.c >> @@ -686,7 +686,7 @@ static void trim_pfn_device(struct nd_pfn *nd_pfn, u32 *start_pad, u32 *end_trun >> if (region_intersects(start, size, IORESOURCE_SYSTEM_RAM, >> IORES_DESC_NONE) == REGION_MIXED >> || !IS_ALIGNED(end, nd_pfn->align) >> - || nd_region_conflict(nd_region, start, size + adjust)) >> + || nd_region_conflict(nd_region, start, size)) > >Good catch, thanks. I fixed up the changelog a bit and applied this: > > libnvdimm, pfn: Fix over-trim in trim_pfn_device() > > When trying to see whether current nd_region intersects with others, > trim_pfn_device() has already calculated the *size* to be expanded to > SECTION size. > > Do not double append 'adjust' to 'size' when calculating whether the end > of a region collides with the next pmem region. Looks much better :-) Thanks > > Fixes: ae86cbfef381 "libnvdimm, pfn: Pad pfn namespaces relative >to other regions" > Cc: <stable@vger.kernel.org> > Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
On Tue, Jan 22, 2019 at 05:28:39PM -0800, Dan Williams wrote: >On Mon, Jan 21, 2019 at 6:49 PM Wei Yang <richardw.yang@linux.intel.com> wrote: >> >> When trying to see whether current nd_region intersects with others, we >> have already calculated the *size* to be expanded to SECTION size. >> >> So just pass size is enough. >> >> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> >> --- >> drivers/nvdimm/pfn_devs.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c >> index becf0bb481b3..5eca050b3660 100644 >> --- a/drivers/nvdimm/pfn_devs.c >> +++ b/drivers/nvdimm/pfn_devs.c >> @@ -686,7 +686,7 @@ static void trim_pfn_device(struct nd_pfn *nd_pfn, u32 *start_pad, u32 *end_trun >> if (region_intersects(start, size, IORESOURCE_SYSTEM_RAM, >> IORES_DESC_NONE) == REGION_MIXED >> || !IS_ALIGNED(end, nd_pfn->align) >> - || nd_region_conflict(nd_region, start, size + adjust)) >> + || nd_region_conflict(nd_region, start, size)) > Hi, Dan, I got a question about the trim on start. We check the alignment of nd_pfn->align on end, while we don't do this for start. I lost why we would like to have this behavior. Would we align start with nd_pfn->align too? >Good catch, thanks. I fixed up the changelog a bit and applied this: > > libnvdimm, pfn: Fix over-trim in trim_pfn_device() > > When trying to see whether current nd_region intersects with others, > trim_pfn_device() has already calculated the *size* to be expanded to > SECTION size. > > Do not double append 'adjust' to 'size' when calculating whether the end > of a region collides with the next pmem region. > > Fixes: ae86cbfef381 "libnvdimm, pfn: Pad pfn namespaces relative >to other regions" > Cc: <stable@vger.kernel.org> > Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index becf0bb481b3..5eca050b3660 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -686,7 +686,7 @@ static void trim_pfn_device(struct nd_pfn *nd_pfn, u32 *start_pad, u32 *end_trun if (region_intersects(start, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) == REGION_MIXED || !IS_ALIGNED(end, nd_pfn->align) - || nd_region_conflict(nd_region, start, size + adjust)) + || nd_region_conflict(nd_region, start, size)) *end_trunc = end - phys_pmem_align_down(nd_pfn, end); }
When trying to see whether current nd_region intersects with others, we have already calculated the *size* to be expanded to SECTION size. So just pass size is enough. Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> --- drivers/nvdimm/pfn_devs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)