Re: [PATCH v3 2/2] ARM64: dts: bcm: Use a symlink to R-Pi dtsi files from arch=arm

2016-10-02 Thread Olof Johansson
On Thu, Aug 18, 2016 at 11:42:06AM +0100, Ian Campbell wrote:
> The ../../../arm... style cross-references added by commit 9d56c22a7861
> ("ARM: bcm2835: Add devicetree for the Raspberry Pi 3.") do not work in the
> context of the split device-tree repository[0] (where the directory
> structure differs). As with commit 8ee57b8182c4 ("ARM64: dts: vexpress: Use
> a symlink to vexpress-v2m-rs1.dtsi from arch=arm") use symlinks instead.
> 
> [0] 
> https://git.kernel.org/cgit/linux/kernel/git/devicetree/devicetree-rebasing.git/
> 
> Signed-off-by: Ian Campbell 
> Acked-by: Mark Rutland 
> Cc: Catalin Marinas 
> Cc: Will Deacon 
> Cc: Mark Rutland 
> Cc: Rob Herring 
> Cc: Frank Rowand 
> Cc: Eric Anholt 
> Cc: Stephen Warren 
> Cc: Lee Jones 
> Cc: Gerd Hoffmann 
> Cc: devicet...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-rpi-ker...@lists.infradead.org
> Cc: a...@kernel.org
> ---
> v2: No more need for skeleton.dtsi since this was cleaned up in the previous
> patch
> v3: Collected tags

Hi,

I still think this is fundamentally the wrong approach. We shouldn't have
created these file links in the first place.

I'd rather have something like this in our tree:

arch/arm64/boot/dts/include/arm -> ../../../../arm/boot/dts
arch/arm64/boot/dts/include/arm64 -> ../..
arch/arm/boot/dts/include/arm64 -> ../../../../arm64/boot/dts
arch/arm/boot/dts/include/arm -> ../..


That way you can include by using  instead.

You'll populate another (or the same) directory with links as appropriate
in your out-of-tree version of the DT contents.

No more symlinked files, and still a clear way of showing that you're
referencing contents out of the other architecture.

Considerably cleaner, isn't it?


-Olof


Re: [PATCH v3 2/2] ARM64: dts: bcm: Use a symlink to R-Pi dtsi files from arch=arm

2016-10-02 Thread Olof Johansson
On Thu, Aug 18, 2016 at 11:42:06AM +0100, Ian Campbell wrote:
> The ../../../arm... style cross-references added by commit 9d56c22a7861
> ("ARM: bcm2835: Add devicetree for the Raspberry Pi 3.") do not work in the
> context of the split device-tree repository[0] (where the directory
> structure differs). As with commit 8ee57b8182c4 ("ARM64: dts: vexpress: Use
> a symlink to vexpress-v2m-rs1.dtsi from arch=arm") use symlinks instead.
> 
> [0] 
> https://git.kernel.org/cgit/linux/kernel/git/devicetree/devicetree-rebasing.git/
> 
> Signed-off-by: Ian Campbell 
> Acked-by: Mark Rutland 
> Cc: Catalin Marinas 
> Cc: Will Deacon 
> Cc: Mark Rutland 
> Cc: Rob Herring 
> Cc: Frank Rowand 
> Cc: Eric Anholt 
> Cc: Stephen Warren 
> Cc: Lee Jones 
> Cc: Gerd Hoffmann 
> Cc: devicet...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-rpi-ker...@lists.infradead.org
> Cc: a...@kernel.org
> ---
> v2: No more need for skeleton.dtsi since this was cleaned up in the previous
> patch
> v3: Collected tags

Hi,

I still think this is fundamentally the wrong approach. We shouldn't have
created these file links in the first place.

I'd rather have something like this in our tree:

arch/arm64/boot/dts/include/arm -> ../../../../arm/boot/dts
arch/arm64/boot/dts/include/arm64 -> ../..
arch/arm/boot/dts/include/arm64 -> ../../../../arm64/boot/dts
arch/arm/boot/dts/include/arm -> ../..


That way you can include by using  instead.

You'll populate another (or the same) directory with links as appropriate
in your out-of-tree version of the DT contents.

No more symlinked files, and still a clear way of showing that you're
referencing contents out of the other architecture.

Considerably cleaner, isn't it?


-Olof


Re: [PATCH 1/2] net/mlx5e: shut up maybe-uninitialized warning

2016-10-02 Thread David Miller
From: Arnd Bergmann 
Date: Fri, 30 Sep 2016 18:17:09 +0200

> Build-testing this driver with -Wmaybe-uninitialized gives a new 
> false-positive
> warning that I can't really explain:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c: In function 
> 'mlx5e_configure_flower':
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:509:3: error: 'old_attr' may 
> be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> It's obvious from the code that 'old_attr' is initialized whenever 'old'
> is non-NULL here. The warning appears with all versions I tested from gcc-4.7
> through gcc-6.1, and I could not come up with a way to rewrite the function
> in a more readable way that avoids the warning, so I'm adding another
> initialization to shut it up.
> 
> Fixes: 8b32580df1cb ("net/mlx5e: Add TC vlan action for SRIOV offloads")
> Signed-off-by: Arnd Bergmann 

Applied.


Re: [PATCH 1/2] net/mlx5e: shut up maybe-uninitialized warning

2016-10-02 Thread David Miller
From: Arnd Bergmann 
Date: Fri, 30 Sep 2016 18:17:09 +0200

> Build-testing this driver with -Wmaybe-uninitialized gives a new 
> false-positive
> warning that I can't really explain:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c: In function 
> 'mlx5e_configure_flower':
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:509:3: error: 'old_attr' may 
> be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> It's obvious from the code that 'old_attr' is initialized whenever 'old'
> is non-NULL here. The warning appears with all versions I tested from gcc-4.7
> through gcc-6.1, and I could not come up with a way to rewrite the function
> in a more readable way that avoids the warning, so I'm adding another
> initialization to shut it up.
> 
> Fixes: 8b32580df1cb ("net/mlx5e: Add TC vlan action for SRIOV offloads")
> Signed-off-by: Arnd Bergmann 

Applied.


Re: [PATCH 2/2] mlxsw: spectrum_router: avoid potential uninitialized data usage

2016-10-02 Thread David Miller
From: Arnd Bergmann 
Date: Fri, 30 Sep 2016 18:17:10 +0200

> If fi->fib_nhs is zero, the router interface pointer is uninitialized, as 
> shown by
> this warning:
> 
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 
> 'mlxsw_sp_router_fib_event':
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:1674:21: error: 'r' may 
> be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:1643:23: note: 'r' was 
> declared here
> 
> This changes the loop so we handle the case the same way as finding no router
> interface pointer attached to one of the nexthops to ensure we always
> trap here instead of using uninitialized data.
> 
> Fixes: b45f64d16d45 ("mlxsw: spectrum_router: Use FIB notifications instead 
> of switchdev calls")
> Signed-off-by: Arnd Bergmann 

Applied.


Re: [PATCH 2/2] mlxsw: spectrum_router: avoid potential uninitialized data usage

2016-10-02 Thread David Miller
From: Arnd Bergmann 
Date: Fri, 30 Sep 2016 18:17:10 +0200

> If fi->fib_nhs is zero, the router interface pointer is uninitialized, as 
> shown by
> this warning:
> 
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 
> 'mlxsw_sp_router_fib_event':
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:1674:21: error: 'r' may 
> be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:1643:23: note: 'r' was 
> declared here
> 
> This changes the loop so we handle the case the same way as finding no router
> interface pointer attached to one of the nexthops to ensure we always
> trap here instead of using uninitialized data.
> 
> Fixes: b45f64d16d45 ("mlxsw: spectrum_router: Use FIB notifications instead 
> of switchdev calls")
> Signed-off-by: Arnd Bergmann 

Applied.


Re: [Nouveau] [PATCH v4 3/3] drm/nouveau/fb/nv50: defer DMA mapping of scratch page to init() hook

2016-10-02 Thread Alexandre Courbot
On Mon, Sep 26, 2016 at 9:32 PM, Ard Biesheuvel
 wrote:
> The 100c08 scratch page is mapped using dma_map_page() before the TTM
> layer has had a chance to set the DMA mask. This means we are still
> running with the default of 32 when this code executes, and this causes
> problems for platforms with no memory below 4 GB (such as AMD Seattle)
>
> So move the dma_map_page() to the .init hook, which executes after the
> DMA mask has been set.

The comments I did on gf100 also apply here. The only difference is
that you will have to create the oneinit hook which does not exist in
this file.

Thanks!


Re: [Nouveau] [PATCH v4 3/3] drm/nouveau/fb/nv50: defer DMA mapping of scratch page to init() hook

2016-10-02 Thread Alexandre Courbot
On Mon, Sep 26, 2016 at 9:32 PM, Ard Biesheuvel
 wrote:
> The 100c08 scratch page is mapped using dma_map_page() before the TTM
> layer has had a chance to set the DMA mask. This means we are still
> running with the default of 32 when this code executes, and this causes
> problems for platforms with no memory below 4 GB (such as AMD Seattle)
>
> So move the dma_map_page() to the .init hook, which executes after the
> DMA mask has been set.

The comments I did on gf100 also apply here. The only difference is
that you will have to create the oneinit hook which does not exist in
this file.

Thanks!


Re: [Nouveau] [PATCH v4 2/3] drm/nouveau/fb/gf100: defer DMA mapping of scratch page to init() hook

2016-10-02 Thread Alexandre Courbot
On Mon, Sep 26, 2016 at 9:32 PM, Ard Biesheuvel
 wrote:
> The 100c10 scratch page is mapped using dma_map_page() before the TTM
> layer has had a chance to set the DMA mask. This means we are still
> running with the default of 32 when this code executes, and this causes
> problems for platforms with no memory below 4 GB (such as AMD Seattle)
>
> So move the dma_map_page() to the .init hook, which executes after the
> DMA mask has been set.
>
> Signed-off-by: Ard Biesheuvel 
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c | 26 ++--
>  1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c 
> b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c
> index 76433cc66fff..5c8132873e60 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c
> @@ -93,7 +93,18 @@ gf100_fb_init(struct nvkm_fb *base)
> struct gf100_fb *fb = gf100_fb(base);
> struct nvkm_device *device = fb->base.subdev.device;
>
> -   if (fb->r100c10_page)
> +   if (!fb->r100c10) {
> +   dma_addr_t addr = dma_map_page(device->dev, fb->r100c10_page, 
> 0,
> +  PAGE_SIZE, DMA_BIDIRECTIONAL);
> +   if (!dma_mapping_error(device->dev, addr)) {
> +   fb->r100c10 = addr;
> +   } else {
> +   nvkm_warn(>base.subdev,
> +"dma_map_page() failed on 100c10 page\n");
> +   }
> +   }
> +
> +   if (fb->r100c10)
> nvkm_wr32(device, 0x100c10, fb->r100c10 >> 8);

gf100_fb_oneinit() seems to be a better place for this, since it will
be executed exactly once, which is what you want for a memory
allocation. As you can see other memory allocations are also performed
there, which hints it should have been done there (and not in ctor) in
the first place. Maybe you can also move the alloc_page() there so
everything is done in the same place.

>  }
>
> @@ -103,12 +114,13 @@ gf100_fb_dtor(struct nvkm_fb *base)
> struct gf100_fb *fb = gf100_fb(base);
> struct nvkm_device *device = fb->base.subdev.device;
>
> -   if (fb->r100c10_page) {
> +   if (fb->r100c10) {
> dma_unmap_page(device->dev, fb->r100c10, PAGE_SIZE,
>DMA_BIDIRECTIONAL);
> -   __free_page(fb->r100c10_page);
> }
>
> +   __free_page(fb->r100c10_page);
> +

If you move the allocation/mapping to gf100_fb_oneinit() then I
suppose you don't need this change.


Re: [Nouveau] [PATCH v4 2/3] drm/nouveau/fb/gf100: defer DMA mapping of scratch page to init() hook

2016-10-02 Thread Alexandre Courbot
On Mon, Sep 26, 2016 at 9:32 PM, Ard Biesheuvel
 wrote:
> The 100c10 scratch page is mapped using dma_map_page() before the TTM
> layer has had a chance to set the DMA mask. This means we are still
> running with the default of 32 when this code executes, and this causes
> problems for platforms with no memory below 4 GB (such as AMD Seattle)
>
> So move the dma_map_page() to the .init hook, which executes after the
> DMA mask has been set.
>
> Signed-off-by: Ard Biesheuvel 
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c | 26 ++--
>  1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c 
> b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c
> index 76433cc66fff..5c8132873e60 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c
> @@ -93,7 +93,18 @@ gf100_fb_init(struct nvkm_fb *base)
> struct gf100_fb *fb = gf100_fb(base);
> struct nvkm_device *device = fb->base.subdev.device;
>
> -   if (fb->r100c10_page)
> +   if (!fb->r100c10) {
> +   dma_addr_t addr = dma_map_page(device->dev, fb->r100c10_page, 
> 0,
> +  PAGE_SIZE, DMA_BIDIRECTIONAL);
> +   if (!dma_mapping_error(device->dev, addr)) {
> +   fb->r100c10 = addr;
> +   } else {
> +   nvkm_warn(>base.subdev,
> +"dma_map_page() failed on 100c10 page\n");
> +   }
> +   }
> +
> +   if (fb->r100c10)
> nvkm_wr32(device, 0x100c10, fb->r100c10 >> 8);

gf100_fb_oneinit() seems to be a better place for this, since it will
be executed exactly once, which is what you want for a memory
allocation. As you can see other memory allocations are also performed
there, which hints it should have been done there (and not in ctor) in
the first place. Maybe you can also move the alloc_page() there so
everything is done in the same place.

>  }
>
> @@ -103,12 +114,13 @@ gf100_fb_dtor(struct nvkm_fb *base)
> struct gf100_fb *fb = gf100_fb(base);
> struct nvkm_device *device = fb->base.subdev.device;
>
> -   if (fb->r100c10_page) {
> +   if (fb->r100c10) {
> dma_unmap_page(device->dev, fb->r100c10, PAGE_SIZE,
>DMA_BIDIRECTIONAL);
> -   __free_page(fb->r100c10_page);
> }
>
> +   __free_page(fb->r100c10_page);
> +

If you move the allocation/mapping to gf100_fb_oneinit() then I
suppose you don't need this change.


Re: [Nouveau] [PATCH v4 1/3] drm/nouveau: set streaming DMA mask early

2016-10-02 Thread Alexandre Courbot
On Mon, Sep 26, 2016 at 9:32 PM, Ard Biesheuvel
 wrote:
> Some subdevices (i.e., fb/nv50.c and fb/gf100.c) map a scratch page using
> dma_map_page() way before the TTM layer has had a chance to set the DMA
> mask. This may prevent the driver from loading at all on platforms whose
> system memory is not covered by the default DMA mask of 32-bit (i.e., when
> all RAM is above 4 GB).
>
> So set a preliminary DMA mask right after constructing the PCI device, and
> base it on the .dma_bits member of the MMU subdevice, which is what the TTM
> layer will base the DMA mask on as well.
>
> Signed-off-by: Ard Biesheuvel 
> ---
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 11 +++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
> b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 652ab111dd74..e61e9a0adb51 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -361,6 +361,17 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
>
> pci_set_master(pdev);
>
> +   /*
> +* Set a preliminary DMA mask based on the .dma_bits member of the
> +* MMU subdevice. This allows other subdevices to create DMA mappings
> +* in their init() function, which are called before the TTM layer 
> sets
> +* the DMA mask definitively.
> +* This is necessary for platforms where the default DMA mask of 32
> +* does not cover any system memory, i.e., when all RAM is > 4 GB.
> +*/
> +   dma_set_mask_and_coherent(device->dev,
> + DMA_BIT_MASK(device->mmu->dma_bits));

I would just move this to nvkm_device_pci_new() so that it perfectly
mirrors the same call done in nvkm_device_tegra_new(), which was done
for the same purpose. Otherwise, looks good to me.


Re: [Nouveau] [PATCH v4 1/3] drm/nouveau: set streaming DMA mask early

2016-10-02 Thread Alexandre Courbot
On Mon, Sep 26, 2016 at 9:32 PM, Ard Biesheuvel
 wrote:
> Some subdevices (i.e., fb/nv50.c and fb/gf100.c) map a scratch page using
> dma_map_page() way before the TTM layer has had a chance to set the DMA
> mask. This may prevent the driver from loading at all on platforms whose
> system memory is not covered by the default DMA mask of 32-bit (i.e., when
> all RAM is above 4 GB).
>
> So set a preliminary DMA mask right after constructing the PCI device, and
> base it on the .dma_bits member of the MMU subdevice, which is what the TTM
> layer will base the DMA mask on as well.
>
> Signed-off-by: Ard Biesheuvel 
> ---
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 11 +++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
> b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 652ab111dd74..e61e9a0adb51 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -361,6 +361,17 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
>
> pci_set_master(pdev);
>
> +   /*
> +* Set a preliminary DMA mask based on the .dma_bits member of the
> +* MMU subdevice. This allows other subdevices to create DMA mappings
> +* in their init() function, which are called before the TTM layer 
> sets
> +* the DMA mask definitively.
> +* This is necessary for platforms where the default DMA mask of 32
> +* does not cover any system memory, i.e., when all RAM is > 4 GB.
> +*/
> +   dma_set_mask_and_coherent(device->dev,
> + DMA_BIT_MASK(device->mmu->dma_bits));

I would just move this to nvkm_device_pci_new() so that it perfectly
mirrors the same call done in nvkm_device_tegra_new(), which was done
for the same purpose. Otherwise, looks good to me.


[PATCH V3 1/2] PCI: add CRS support to error handling path

2016-10-02 Thread Sinan Kaya
The PCIE spec allows an endpoint device to extend the initialization time
beyond 1 second by issuing Configuration Request Retry Status (CRS) for a
vendor ID read request.

This basically means "I'm busy now, please call me back later".

There are two moving parts to CRS support from the SW perspective. One part
is to determine if CRS is supported or not. The second part is to set the
CRS visibility register.

As part of the probe, the Linux kernel sets the above two conditions in
pci_enable_crs function. The kernel is also honoring the returned CRS in
pci_bus_read_dev_vendor_id function if supported. The function will poll up
to specified amount of time while endpoint is returning CRS response.

The PCIe spec also allows CRS to be issued during cold, warm, hot and FLR
resets.

The hot reset is initiated by starting a secondary bus reset. A bus/device
restore follows the reset.  This patch is adding vendor ID read into dev
restore function to validate that the device is accessible before writing
the register contents. If the device issues CRS, the code might poll up
to 60 seconds.

Signed-off-by: Sinan Kaya 
---
 drivers/pci/pci.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index aab9d51..c8749b9 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4020,6 +4020,12 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)
 
 static void pci_dev_restore(struct pci_dev *dev)
 {
+   u32 l;
+
+   /* see if the device is accessible first */
+   if (!pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, , 60 * 1000))
+   return;
+
pci_restore_state(dev);
pci_reset_notify(dev, false);
 }
-- 
1.9.1



[PATCH V3 2/2] PCI: handle CRS returned by device after FLR

2016-10-02 Thread Sinan Kaya
An endpoint is allowed to issue CRS following an FLR request to indicate
that it is not ready to accept new requests. Changing the polling mechanism
in FLR wait function to go read the vendor ID instead of the command/status
register. A CRS indication will only be given if the address to be read is
vendor ID.

Signed-off-by: Sinan Kaya 
---
 drivers/pci/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c8749b9..7580b00 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3725,7 +3725,8 @@ static void pci_flr_wait(struct pci_dev *dev)
 
do {
msleep(100);
-   pci_read_config_dword(dev, PCI_COMMAND, );
+   pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, ,
+  60 * 1000);
} while (i++ < 10 && id == ~0);
 
if (id == ~0)
-- 
1.9.1



[PATCH V3 0/2] PCI: add CRS support after hot reset and FLR

2016-10-02 Thread Sinan Kaya
The PCIE spec allows an endpoint device to extend the initialization time
beyond 1 second by issuing Configuration Request Retry Status (CRS) for a
vendor ID read request.

This basically means "I'm busy now, please call me back later".

There are two moving parts to CRS support from the SW perspective. One part
is to determine if CRS is supported or not. The second part is to set the
CRS visibility register.

As part of the probe, the Linux kernel sets the above two conditions in
pci_enable_crs function. The kernel is also honoring the returned CRS in
pci_bus_read_dev_vendor_id function if supported. The function will poll up
to specified amount of time while endpoint is returning CRS response.

The PCIe spec also allows CRS to be issued during cold, warm, hot and FLR
resets.

The hot reset is initiated by starting a secondary bus reset. A bus/device
restore follows the reset.  This patch is adding vendor ID read into dev
restore function to validate that the device is accessible before writing
the register contents. If the device issues CRS, the code might poll up
to 60 seconds.

An endpoint is allowed to issue CRS following an FLR request to indicate
that it is not ready to accept new requests. Changing the polling mechanism
in FLR wait function to go read the vendor ID instead of the command/status
register. A CRS indication will only be given if the address to be read is
vendor ID.

v3:
* dropped parent_bus_reset change and IB/hfi1 changes as both of them work
only when there is a single device on the bus and reset is for the device
in the bus. 
* dropper AER changes as AER driver broadcasts error to the endpoint device
driver which eventually cause endpoint driver to be reprobed after fatal 
error. 
* moved vendor id read into the pci_dev_restore function as this is the
* first
attempt to contact the endpoint after a reset.

v2:
http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1233472.html
* IB/hfi1 via pci_reset_bridge_secondary_bus
* PCI/AER via pci_reset_bridge_secondary_bus
* PCI: dev_reset via parent bus reset
* use walk_bus for vendor id reads since the lock is no longer held.

v1:
http://www.spinics.net/lists/linux-pci/msg53596.html

* initial implementation

Sinan Kaya (2):
  PCI: add CRS support to error handling path
  PCI: handle CRS returned by device after FLR

 drivers/pci/pci.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

-- 
1.9.1



[PATCH V3 0/2] PCI: add CRS support after hot reset and FLR

2016-10-02 Thread Sinan Kaya
The PCIE spec allows an endpoint device to extend the initialization time
beyond 1 second by issuing Configuration Request Retry Status (CRS) for a
vendor ID read request.

This basically means "I'm busy now, please call me back later".

There are two moving parts to CRS support from the SW perspective. One part
is to determine if CRS is supported or not. The second part is to set the
CRS visibility register.

As part of the probe, the Linux kernel sets the above two conditions in
pci_enable_crs function. The kernel is also honoring the returned CRS in
pci_bus_read_dev_vendor_id function if supported. The function will poll up
to specified amount of time while endpoint is returning CRS response.

The PCIe spec also allows CRS to be issued during cold, warm, hot and FLR
resets.

The hot reset is initiated by starting a secondary bus reset. A bus/device
restore follows the reset.  This patch is adding vendor ID read into dev
restore function to validate that the device is accessible before writing
the register contents. If the device issues CRS, the code might poll up
to 60 seconds.

An endpoint is allowed to issue CRS following an FLR request to indicate
that it is not ready to accept new requests. Changing the polling mechanism
in FLR wait function to go read the vendor ID instead of the command/status
register. A CRS indication will only be given if the address to be read is
vendor ID.

v3:
* dropped parent_bus_reset change and IB/hfi1 changes as both of them work
only when there is a single device on the bus and reset is for the device
in the bus. 
* dropper AER changes as AER driver broadcasts error to the endpoint device
driver which eventually cause endpoint driver to be reprobed after fatal 
error. 
* moved vendor id read into the pci_dev_restore function as this is the
* first
attempt to contact the endpoint after a reset.

v2:
http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1233472.html
* IB/hfi1 via pci_reset_bridge_secondary_bus
* PCI/AER via pci_reset_bridge_secondary_bus
* PCI: dev_reset via parent bus reset
* use walk_bus for vendor id reads since the lock is no longer held.

v1:
http://www.spinics.net/lists/linux-pci/msg53596.html

* initial implementation

Sinan Kaya (2):
  PCI: add CRS support to error handling path
  PCI: handle CRS returned by device after FLR

 drivers/pci/pci.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

-- 
1.9.1



[PATCH V3 1/2] PCI: add CRS support to error handling path

2016-10-02 Thread Sinan Kaya
The PCIE spec allows an endpoint device to extend the initialization time
beyond 1 second by issuing Configuration Request Retry Status (CRS) for a
vendor ID read request.

This basically means "I'm busy now, please call me back later".

There are two moving parts to CRS support from the SW perspective. One part
is to determine if CRS is supported or not. The second part is to set the
CRS visibility register.

As part of the probe, the Linux kernel sets the above two conditions in
pci_enable_crs function. The kernel is also honoring the returned CRS in
pci_bus_read_dev_vendor_id function if supported. The function will poll up
to specified amount of time while endpoint is returning CRS response.

The PCIe spec also allows CRS to be issued during cold, warm, hot and FLR
resets.

The hot reset is initiated by starting a secondary bus reset. A bus/device
restore follows the reset.  This patch is adding vendor ID read into dev
restore function to validate that the device is accessible before writing
the register contents. If the device issues CRS, the code might poll up
to 60 seconds.

Signed-off-by: Sinan Kaya 
---
 drivers/pci/pci.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index aab9d51..c8749b9 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4020,6 +4020,12 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)
 
 static void pci_dev_restore(struct pci_dev *dev)
 {
+   u32 l;
+
+   /* see if the device is accessible first */
+   if (!pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, , 60 * 1000))
+   return;
+
pci_restore_state(dev);
pci_reset_notify(dev, false);
 }
-- 
1.9.1



[PATCH V3 2/2] PCI: handle CRS returned by device after FLR

2016-10-02 Thread Sinan Kaya
An endpoint is allowed to issue CRS following an FLR request to indicate
that it is not ready to accept new requests. Changing the polling mechanism
in FLR wait function to go read the vendor ID instead of the command/status
register. A CRS indication will only be given if the address to be read is
vendor ID.

Signed-off-by: Sinan Kaya 
---
 drivers/pci/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c8749b9..7580b00 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3725,7 +3725,8 @@ static void pci_flr_wait(struct pci_dev *dev)
 
do {
msleep(100);
-   pci_read_config_dword(dev, PCI_COMMAND, );
+   pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, ,
+  60 * 1000);
} while (i++ < 10 && id == ~0);
 
if (id == ~0)
-- 
1.9.1



Re: [PATCH] cxgb4: unexport cxgb4_dcb_enabled

2016-10-02 Thread David Miller
From: Arnd Bergmann 
Date: Fri, 30 Sep 2016 18:15:33 +0200

> A recent cleanup marked cxgb4_dcb_enabled as 'static', which is correct, but 
> this ignored
> how the symbol is also exported. In addition, the export can be compiled out 
> when modules
> are disabled, causing a harmless compiler warning in configurations for which 
> it is not
> used at all:
> 
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:282:12: error: 
> 'cxgb4_dcb_enabled' defined but not used [-Werror=unused-function]
> 
> This removes the export and moves the function into the correct #ifdef so we 
> only build
> it when there are users.
> 
> Fixes: 50935857f878 ("cxgb4: mark symbols static where possible")
> Signed-off-by: Arnd Bergmann 

Applied.


Re: [PATCH] cxgb4: unexport cxgb4_dcb_enabled

2016-10-02 Thread David Miller
From: Arnd Bergmann 
Date: Fri, 30 Sep 2016 18:15:33 +0200

> A recent cleanup marked cxgb4_dcb_enabled as 'static', which is correct, but 
> this ignored
> how the symbol is also exported. In addition, the export can be compiled out 
> when modules
> are disabled, causing a harmless compiler warning in configurations for which 
> it is not
> used at all:
> 
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:282:12: error: 
> 'cxgb4_dcb_enabled' defined but not used [-Werror=unused-function]
> 
> This removes the export and moves the function into the correct #ifdef so we 
> only build
> it when there are users.
> 
> Fixes: 50935857f878 ("cxgb4: mark symbols static where possible")
> Signed-off-by: Arnd Bergmann 

Applied.


Re: [PATCH] net: rtnl: avoid uninitialized data in IFLA_VF_VLAN_LIST handling

2016-10-02 Thread David Miller
From: Arnd Bergmann 
Date: Fri, 30 Sep 2016 18:13:49 +0200

> With the newly added support for IFLA_VF_VLAN_LIST netlink messages,
> we get a warning about potential uninitialized variable use in
> the parsing of the user input when enabling the -Wmaybe-uninitialized
> warning:
> 
> net/core/rtnetlink.c: In function 'do_setvfinfo':
> net/core/rtnetlink.c:1756:9: error: 'ivvl$' may be used uninitialized in this 
> function [-Werror=maybe-uninitialized]
> 
> I have not been able to prove whether it is possible to arrive in
> this code with an empty IFLA_VF_VLAN_LIST block, but if we do,
> then ndo_set_vf_vlan gets called with uninitialized arguments.
> 
> This adds an explicit check for an empty list, making it obvious
> to the reader and the compiler that this cannot happen.
> 
> Fixes: 79aab093a0b5 ("net: Update API for VF vlan protocol 802.1ad support")
> Signed-off-by: Arnd Bergmann 

Applied, thanks.


Re: [PATCH] net: rtnl: avoid uninitialized data in IFLA_VF_VLAN_LIST handling

2016-10-02 Thread David Miller
From: Arnd Bergmann 
Date: Fri, 30 Sep 2016 18:13:49 +0200

> With the newly added support for IFLA_VF_VLAN_LIST netlink messages,
> we get a warning about potential uninitialized variable use in
> the parsing of the user input when enabling the -Wmaybe-uninitialized
> warning:
> 
> net/core/rtnetlink.c: In function 'do_setvfinfo':
> net/core/rtnetlink.c:1756:9: error: 'ivvl$' may be used uninitialized in this 
> function [-Werror=maybe-uninitialized]
> 
> I have not been able to prove whether it is possible to arrive in
> this code with an empty IFLA_VF_VLAN_LIST block, but if we do,
> then ndo_set_vf_vlan gets called with uninitialized arguments.
> 
> This adds an explicit check for an empty list, making it obvious
> to the reader and the compiler that this cannot happen.
> 
> Fixes: 79aab093a0b5 ("net: Update API for VF vlan protocol 802.1ad support")
> Signed-off-by: Arnd Bergmann 

Applied, thanks.


Re: [PATCH] net: ethernet: mediatek: mark symbols static where possible

2016-10-02 Thread David Miller
From: Baoyou Xie 
Date: Fri, 30 Sep 2016 15:48:50 +0800

> We get 2 warnings when building kernel with W=1:
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:2041:5: warning: no previous 
> prototype for 'mtk_get_link_ksettings' [-Wmissing-prototypes]
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:2052:5: warning: no previous 
> prototype for 'mtk_set_link_ksettings' [-Wmissing-prototypes]
> 
> In fact, these functions are only used in the file in which they are
> declared and don't need a declaration, but can be made static.
> So this patch marks these functions with 'static'.
> 
> Signed-off-by: Baoyou Xie 

Applied, thanks.


Re: [PATCH] net: ethernet: mediatek: mark symbols static where possible

2016-10-02 Thread David Miller
From: Baoyou Xie 
Date: Fri, 30 Sep 2016 15:48:50 +0800

> We get 2 warnings when building kernel with W=1:
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:2041:5: warning: no previous 
> prototype for 'mtk_get_link_ksettings' [-Wmissing-prototypes]
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:2052:5: warning: no previous 
> prototype for 'mtk_set_link_ksettings' [-Wmissing-prototypes]
> 
> In fact, these functions are only used in the file in which they are
> declared and don't need a declaration, but can be made static.
> So this patch marks these functions with 'static'.
> 
> Signed-off-by: Baoyou Xie 

Applied, thanks.


Re: [PATCH] cxgb4: mark cxgb_setup_tc() static

2016-10-02 Thread David Miller
From: Baoyou Xie 
Date: Fri, 30 Sep 2016 15:34:25 +0800

> We get 1 warning when building kernel with W=1:
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:2715:5: warning: no previous 
> prototype for 'cxgb_setup_tc' [-Wmissing-prototypes]
> 
> In fact, this function is only used in the file in which it is
> declared and don't need a declaration, but can be made static.
> so this patch marks this function with 'static'.
> 
> Signed-off-by: Baoyou Xie 

Applied.


Re: [PATCH] cxgb4: mark cxgb_setup_tc() static

2016-10-02 Thread David Miller
From: Baoyou Xie 
Date: Fri, 30 Sep 2016 15:34:25 +0800

> We get 1 warning when building kernel with W=1:
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:2715:5: warning: no previous 
> prototype for 'cxgb_setup_tc' [-Wmissing-prototypes]
> 
> In fact, this function is only used in the file in which it is
> declared and don't need a declaration, but can be made static.
> so this patch marks this function with 'static'.
> 
> Signed-off-by: Baoyou Xie 

Applied.


Re: [lustre-devel] [PATCH] staging: lustre: ko2iblbd: handle ib_dereg_mr removal

2016-10-02 Thread Dilger, Andreas
On Oct 2, 2016, at 20:22, James Simmons  wrote:
> 
> In the rdma-next tree to be merged for 4.9-rc1 removes
> the IB core function ib_get_dma_mr. This patch migrates
> us way from this former function.
> 
> Signed-off-by: James Simmons 
> ---
> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   19 ---
> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|5 +
> 2 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
> b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index c7a5d49..4010591 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1316,7 +1316,7 @@ static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool 
> *fpo)
>   list_for_each_entry_safe(frd, tmp, >fast_reg.fpo_pool_list,
>frd_list) {
>   list_del(>frd_list);
> - ib_dereg_mr(frd->frd_mr);
> + kib_dereg_mr(fpo->fpo_hdev, frd->frd_mr);
>   LIBCFS_FREE(frd, sizeof(*frd));
>   i++;
>   }
> @@ -1422,14 +1422,14 @@ static int kiblnd_alloc_freg_pool(struct 
> kib_fmr_poolset *fps, struct kib_fmr_po
> 
> out_middle:
>   if (frd->frd_mr)
> - ib_dereg_mr(frd->frd_mr);
> + kib_dereg_mr(fpo->fpo_hdev, frd->frd_mr);
>   LIBCFS_FREE(frd, sizeof(*frd));
> 
> out:
>   list_for_each_entry_safe(frd, tmp, >fast_reg.fpo_pool_list,
>frd_list) {
>   list_del(>frd_list);
> - ib_dereg_mr(frd->frd_mr);
> + kib_dereg_mr(fpo->fpo_hdev, frd->frd_mr);
>   LIBCFS_FREE(frd, sizeof(*frd));
>   }
> 
> @@ -2288,8 +2288,8 @@ static void kiblnd_hdev_cleanup_mrs(struct kib_hca_dev 
> *hdev)
>   if (!hdev->ibh_mrs)
>   return;
> 
> - ib_dereg_mr(hdev->ibh_mrs);
> -
> + kib_dereg_mr(hdev, hdev->ibh_mrs);
> + hdev->ibh_pd->device->dereg_mr(hdev->ibh_mrs);

This should only call one of kib_dereg_mr() or hdev->...->dereg_mr() ?

>   hdev->ibh_mrs = NULL;
> }
> 
> @@ -2316,13 +2316,18 @@ static int kiblnd_hdev_setup_mrs(struct kib_hca_dev 
> *hdev)
>   if (rc)
>   return rc;
> 
> - mr = ib_get_dma_mr(hdev->ibh_pd, acflags);
> + mr = hdev->ibh_pd->device->get_dma_mr(hdev->ibh_pd, acflags);

Should we make a similar wrapper function kib_get_dma_mr()?

Cheers, Andreas

>   if (IS_ERR(mr)) {
> - CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr));
> + CERROR("Failed device get_dma_mr : %ld\n", PTR_ERR(mr));
>   kiblnd_hdev_cleanup_mrs(hdev);
>   return PTR_ERR(mr);
>   }
> 
> + mr->device = hdev->ibh_pd->device;
> + mr->pd = hdev->ibh_pd;
> + mr->uobject = NULL;
> + mr->need_inval = false;
> +
>   hdev->ibh_mrs = mr;
> 
>   return 0;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h 
> b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> index 1457697..f8b49c5 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> @@ -178,6 +178,11 @@ struct kib_hca_dev {
>   atomic_t   ibh_ref; /* refcount */
> };
> 
> +static inline void kib_dereg_mr(struct kib_hca_dev *hdev, struct ib_mr *mr)
> +{
> + hdev->ibh_pd->device->dereg_mr(mr);
> +}
> +
> /** # of seconds to keep pool alive */
> #define IBLND_POOL_DEADLINE 300
> /** # of seconds to retry if allocation failed */
> -- 
> 1.7.1
> 
> ___
> lustre-devel mailing list
> lustre-de...@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org



Re: [lustre-devel] [PATCH] staging: lustre: ko2iblbd: handle ib_dereg_mr removal

2016-10-02 Thread Dilger, Andreas
On Oct 2, 2016, at 20:22, James Simmons  wrote:
> 
> In the rdma-next tree to be merged for 4.9-rc1 removes
> the IB core function ib_get_dma_mr. This patch migrates
> us way from this former function.
> 
> Signed-off-by: James Simmons 
> ---
> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   19 ---
> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|5 +
> 2 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
> b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index c7a5d49..4010591 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1316,7 +1316,7 @@ static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool 
> *fpo)
>   list_for_each_entry_safe(frd, tmp, >fast_reg.fpo_pool_list,
>frd_list) {
>   list_del(>frd_list);
> - ib_dereg_mr(frd->frd_mr);
> + kib_dereg_mr(fpo->fpo_hdev, frd->frd_mr);
>   LIBCFS_FREE(frd, sizeof(*frd));
>   i++;
>   }
> @@ -1422,14 +1422,14 @@ static int kiblnd_alloc_freg_pool(struct 
> kib_fmr_poolset *fps, struct kib_fmr_po
> 
> out_middle:
>   if (frd->frd_mr)
> - ib_dereg_mr(frd->frd_mr);
> + kib_dereg_mr(fpo->fpo_hdev, frd->frd_mr);
>   LIBCFS_FREE(frd, sizeof(*frd));
> 
> out:
>   list_for_each_entry_safe(frd, tmp, >fast_reg.fpo_pool_list,
>frd_list) {
>   list_del(>frd_list);
> - ib_dereg_mr(frd->frd_mr);
> + kib_dereg_mr(fpo->fpo_hdev, frd->frd_mr);
>   LIBCFS_FREE(frd, sizeof(*frd));
>   }
> 
> @@ -2288,8 +2288,8 @@ static void kiblnd_hdev_cleanup_mrs(struct kib_hca_dev 
> *hdev)
>   if (!hdev->ibh_mrs)
>   return;
> 
> - ib_dereg_mr(hdev->ibh_mrs);
> -
> + kib_dereg_mr(hdev, hdev->ibh_mrs);
> + hdev->ibh_pd->device->dereg_mr(hdev->ibh_mrs);

This should only call one of kib_dereg_mr() or hdev->...->dereg_mr() ?

>   hdev->ibh_mrs = NULL;
> }
> 
> @@ -2316,13 +2316,18 @@ static int kiblnd_hdev_setup_mrs(struct kib_hca_dev 
> *hdev)
>   if (rc)
>   return rc;
> 
> - mr = ib_get_dma_mr(hdev->ibh_pd, acflags);
> + mr = hdev->ibh_pd->device->get_dma_mr(hdev->ibh_pd, acflags);

Should we make a similar wrapper function kib_get_dma_mr()?

Cheers, Andreas

>   if (IS_ERR(mr)) {
> - CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr));
> + CERROR("Failed device get_dma_mr : %ld\n", PTR_ERR(mr));
>   kiblnd_hdev_cleanup_mrs(hdev);
>   return PTR_ERR(mr);
>   }
> 
> + mr->device = hdev->ibh_pd->device;
> + mr->pd = hdev->ibh_pd;
> + mr->uobject = NULL;
> + mr->need_inval = false;
> +
>   hdev->ibh_mrs = mr;
> 
>   return 0;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h 
> b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> index 1457697..f8b49c5 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> @@ -178,6 +178,11 @@ struct kib_hca_dev {
>   atomic_t   ibh_ref; /* refcount */
> };
> 
> +static inline void kib_dereg_mr(struct kib_hca_dev *hdev, struct ib_mr *mr)
> +{
> + hdev->ibh_pd->device->dereg_mr(mr);
> +}
> +
> /** # of seconds to keep pool alive */
> #define IBLND_POOL_DEADLINE 300
> /** # of seconds to retry if allocation failed */
> -- 
> 1.7.1
> 
> ___
> lustre-devel mailing list
> lustre-de...@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org



Re: [PATCH v4 0/2] Avoid selftests on some Asus models

2016-10-02 Thread Dmitry Torokhov
On Sat, Oct 01, 2016 at 07:56:37AM -0300, Marcos Paulo de Souza wrote:
> ping?

Sorry for the delay, I was trying to wrap my mind around the new
always/never/sometimes logic.

Does the version below still work for you?

Thanks.

-- 
Dmitry

Input: i8042 - skip selftest on ASUS laptops

From: Marcos Paulo de Souza 

On suspend/resume cycle, selftest is executed to reset i8042 controller.
But when this is done in Asus devices, subsequent calls to detect/init
functions to elantech driver fails. Skipping selftest fixes this problem.

An easier step to reproduce this problem is adding i8042.reset=1 as a
kernel parameter. On Asus laptops, it'll make the system to start with the
touchpad already stuck, since psmouse_probe forcibly calls the selftest
function.

This patch was inspired by John Hiesey's change[1], but, since this problem
affects a lot of models of Asus, let's avoid running selftests on them.

All models affected by this problem:
A455LD
K401LB
K501LB
K501LX
R409L
V502LX
X302LA
X450LCP
X450LD
X455LAB
X455LDB
X455LF
Z450LA

[1]: https://marc.info/?l=linux-input=144312209020616=2

Fixes: "ETPS/2 Elantech Touchpad dies after resume from suspend"
(https://bugzilla.kernel.org/show_bug.cgi?id=107971)

Signed-off-by: Marcos Paulo de Souza 
Signed-off-by: Dmitry Torokhov 
---
 Documentation/kernel-parameters.txt |9 +++
 drivers/input/serio/i8042-io.h  |2 -
 drivers/input/serio/i8042-ip22io.h  |2 -
 drivers/input/serio/i8042-ppcio.h   |2 -
 drivers/input/serio/i8042-sparcio.h |2 -
 drivers/input/serio/i8042-unicore32io.h |2 -
 drivers/input/serio/i8042-x86ia64io.h   |   96 ++-
 drivers/input/serio/i8042.c |   55 ++
 8 files changed, 150 insertions(+), 20 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index a4f4d69..46726d4 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1457,7 +1457,14 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
 controllers
i8042.notimeout [HW] Ignore timeout condition signalled by controller
-   i8042.reset [HW] Reset the controller during init and cleanup
+   i8042.reset [HW] Reset the controller during init, cleanup and
+suspend-to-ram transitions, only during s2r
+transitions, or never reset
+   Format: { 1 | Y | y | 0 | N | n }
+   1, Y, y: always reset controller
+   0, N, n: don't ever reset controller
+   Default: only on s2r transitions on x86; most other
+   architectures force reset to be always executed
i8042.unlock[HW] Unlock (ignore) the keylock
i8042.kbdreset  [HW] Reset device connected to KBD port
 
diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
index a5eed2a..34da81c 100644
--- a/drivers/input/serio/i8042-io.h
+++ b/drivers/input/serio/i8042-io.h
@@ -81,7 +81,7 @@ static inline int i8042_platform_init(void)
return -EBUSY;
 #endif
 
-   i8042_reset = 1;
+   i8042_reset = I8042_RESET_ALWAYS;
return 0;
 }
 
diff --git a/drivers/input/serio/i8042-ip22io.h 
b/drivers/input/serio/i8042-ip22io.h
index ee1ad27..08a1c10 100644
--- a/drivers/input/serio/i8042-ip22io.h
+++ b/drivers/input/serio/i8042-ip22io.h
@@ -61,7 +61,7 @@ static inline int i8042_platform_init(void)
return -EBUSY;
 #endif
 
-   i8042_reset = 1;
+   i8042_reset = I8042_RESET_ALWAYS;
 
return 0;
 }
diff --git a/drivers/input/serio/i8042-ppcio.h 
b/drivers/input/serio/i8042-ppcio.h
index f708c75..1aabea4 100644
--- a/drivers/input/serio/i8042-ppcio.h
+++ b/drivers/input/serio/i8042-ppcio.h
@@ -44,7 +44,7 @@ static inline void i8042_write_command(int val)
 
 static inline int i8042_platform_init(void)
 {
-   i8042_reset = 1;
+   i8042_reset = I8042_RESET_ALWAYS;
return 0;
 }
 
diff --git a/drivers/input/serio/i8042-sparcio.h 
b/drivers/input/serio/i8042-sparcio.h
index afcd1c1..6231d63 100644
--- a/drivers/input/serio/i8042-sparcio.h
+++ b/drivers/input/serio/i8042-sparcio.h
@@ -130,7 +130,7 @@ static int __init i8042_platform_init(void)
}
}
 
-   i8042_reset = 1;
+   i8042_reset = I8042_RESET_ALWAYS;
 
return 0;
 }
diff --git a/drivers/input/serio/i8042-unicore32io.h 
b/drivers/input/serio/i8042-unicore32io.h
index 73f5cc1..4557475 100644
--- a/drivers/input/serio/i8042-unicore32io.h
+++ b/drivers/input/serio/i8042-unicore32io.h
@@ -61,7 +61,7 @@ static inline int i8042_platform_init(void)
if (!request_mem_region(I8042_REGION_START, 

Re: [PATCH v4 0/2] Avoid selftests on some Asus models

2016-10-02 Thread Dmitry Torokhov
On Sat, Oct 01, 2016 at 07:56:37AM -0300, Marcos Paulo de Souza wrote:
> ping?

Sorry for the delay, I was trying to wrap my mind around the new
always/never/sometimes logic.

Does the version below still work for you?

Thanks.

-- 
Dmitry

Input: i8042 - skip selftest on ASUS laptops

From: Marcos Paulo de Souza 

On suspend/resume cycle, selftest is executed to reset i8042 controller.
But when this is done in Asus devices, subsequent calls to detect/init
functions to elantech driver fails. Skipping selftest fixes this problem.

An easier step to reproduce this problem is adding i8042.reset=1 as a
kernel parameter. On Asus laptops, it'll make the system to start with the
touchpad already stuck, since psmouse_probe forcibly calls the selftest
function.

This patch was inspired by John Hiesey's change[1], but, since this problem
affects a lot of models of Asus, let's avoid running selftests on them.

All models affected by this problem:
A455LD
K401LB
K501LB
K501LX
R409L
V502LX
X302LA
X450LCP
X450LD
X455LAB
X455LDB
X455LF
Z450LA

[1]: https://marc.info/?l=linux-input=144312209020616=2

Fixes: "ETPS/2 Elantech Touchpad dies after resume from suspend"
(https://bugzilla.kernel.org/show_bug.cgi?id=107971)

Signed-off-by: Marcos Paulo de Souza 
Signed-off-by: Dmitry Torokhov 
---
 Documentation/kernel-parameters.txt |9 +++
 drivers/input/serio/i8042-io.h  |2 -
 drivers/input/serio/i8042-ip22io.h  |2 -
 drivers/input/serio/i8042-ppcio.h   |2 -
 drivers/input/serio/i8042-sparcio.h |2 -
 drivers/input/serio/i8042-unicore32io.h |2 -
 drivers/input/serio/i8042-x86ia64io.h   |   96 ++-
 drivers/input/serio/i8042.c |   55 ++
 8 files changed, 150 insertions(+), 20 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index a4f4d69..46726d4 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1457,7 +1457,14 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
 controllers
i8042.notimeout [HW] Ignore timeout condition signalled by controller
-   i8042.reset [HW] Reset the controller during init and cleanup
+   i8042.reset [HW] Reset the controller during init, cleanup and
+suspend-to-ram transitions, only during s2r
+transitions, or never reset
+   Format: { 1 | Y | y | 0 | N | n }
+   1, Y, y: always reset controller
+   0, N, n: don't ever reset controller
+   Default: only on s2r transitions on x86; most other
+   architectures force reset to be always executed
i8042.unlock[HW] Unlock (ignore) the keylock
i8042.kbdreset  [HW] Reset device connected to KBD port
 
diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
index a5eed2a..34da81c 100644
--- a/drivers/input/serio/i8042-io.h
+++ b/drivers/input/serio/i8042-io.h
@@ -81,7 +81,7 @@ static inline int i8042_platform_init(void)
return -EBUSY;
 #endif
 
-   i8042_reset = 1;
+   i8042_reset = I8042_RESET_ALWAYS;
return 0;
 }
 
diff --git a/drivers/input/serio/i8042-ip22io.h 
b/drivers/input/serio/i8042-ip22io.h
index ee1ad27..08a1c10 100644
--- a/drivers/input/serio/i8042-ip22io.h
+++ b/drivers/input/serio/i8042-ip22io.h
@@ -61,7 +61,7 @@ static inline int i8042_platform_init(void)
return -EBUSY;
 #endif
 
-   i8042_reset = 1;
+   i8042_reset = I8042_RESET_ALWAYS;
 
return 0;
 }
diff --git a/drivers/input/serio/i8042-ppcio.h 
b/drivers/input/serio/i8042-ppcio.h
index f708c75..1aabea4 100644
--- a/drivers/input/serio/i8042-ppcio.h
+++ b/drivers/input/serio/i8042-ppcio.h
@@ -44,7 +44,7 @@ static inline void i8042_write_command(int val)
 
 static inline int i8042_platform_init(void)
 {
-   i8042_reset = 1;
+   i8042_reset = I8042_RESET_ALWAYS;
return 0;
 }
 
diff --git a/drivers/input/serio/i8042-sparcio.h 
b/drivers/input/serio/i8042-sparcio.h
index afcd1c1..6231d63 100644
--- a/drivers/input/serio/i8042-sparcio.h
+++ b/drivers/input/serio/i8042-sparcio.h
@@ -130,7 +130,7 @@ static int __init i8042_platform_init(void)
}
}
 
-   i8042_reset = 1;
+   i8042_reset = I8042_RESET_ALWAYS;
 
return 0;
 }
diff --git a/drivers/input/serio/i8042-unicore32io.h 
b/drivers/input/serio/i8042-unicore32io.h
index 73f5cc1..4557475 100644
--- a/drivers/input/serio/i8042-unicore32io.h
+++ b/drivers/input/serio/i8042-unicore32io.h
@@ -61,7 +61,7 @@ static inline int i8042_platform_init(void)
if (!request_mem_region(I8042_REGION_START, I8042_REGION_SIZE, "i8042"))
return -EBUSY;
 
-   i8042_reset = 1;
+   

linux-next: Tree for Oct 3

2016-10-02 Thread Stephen Rothwell
Hi all,

Changes since 20160930:

The net-next tree gained conflicts against Linus' tree.

The mac80211-next tree gained conflicts against Linus' tree.

The xen-tip tree gained conflicts againt the tip tree.

The tty tree lost its build failure.

Non-merge commits (relative to Linus' tree): 13450
 9993 files changed, 554934 insertions(+), 300943 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig (with
CONFIG_BUILD_DOCSRC=n) for x86_64, a multi_v7_defconfig for arm and a
native build of tools/perf. After the final fixups (if any), I do an
x86_64 modules_install followed by builds for x86_64 allnoconfig,
powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig
(this fails its final link) and pseries_le_defconfig and i386, sparc
and sparc64 defconfig.

Below is a summary of the state of the merge.

I am currently merging 243 trees (counting Linus' and 34 trees of patches
pending for Linus' tree).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (be67d60ba944 Merge branch 'x86-urgent-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip)
Merging fixes/master (d3396e1e4ec4 Merge tag 'fixes-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc)
Merging kbuild-current/rc-fixes (d3e2773c4ede builddeb: Skip gcc-plugins when 
not configured)
Merging arc-current/for-curr (3eab887a5542 Linux 4.8-rc4)
Merging arm-current/fixes (d248220f0465 ARM: 8617/1: dma: fix dma_max_pfn())
Merging m68k-current/for-linus (6bd80f372371 m68k/defconfig: Update defconfigs 
for v4.7-rc2)
Merging metag-fixes/fixes (97b1d23f7bcb metag: Drop show_mem() from mem_init())
Merging powerpc-fixes/fixes (b79331a5eb9f powerpc/powernv/pci: Fix m64 checks 
for SR-IOV and window alignment)
Merging sparc/master (2a0100d7beeb sparc64: Fix non-SMP build.)
Merging net/master (1cceda784980 sctp: fix the issue sctp_diag uses lock_sock 
in rcu_read_lock)
Merging ipsec/master (b1f2beb87bb0 Merge tag 'media/v4.8-7' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media)
Merging netfilter/master (440f895aa97f drivers: net: phy: xgene: Fix 'remove' 
function)
Merging ipvs/master (ea43f860d984 Merge branch 'ethoc-fixes')
Merging wireless-drivers/master (db64c5fa590b Merge tag 
'iwlwifi-for-kalle-2016-09-15' of 
git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes)
Merging mac80211/master (7ac327318e09 Merge tag 'mac80211-for-davem-2016-09-16' 
of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211)
Merging sound-current/for-linus (eeea8b40cd28 Merge tag 'asoc-v4.9' of 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next)
Merging pci-current/for-linus (035ee288ae7a PCI: Fix bridge_d3 update on device 
removal)
Merging driver-core.current/driver-core-linus (c6935931c189 Linux 4.8-rc5)
Merging tty.current/tty-linus (c6935931c189 Linux 4.8-rc5)
Merging usb.current/usb-linus (3be7988674ab Linux 4.8-rc7)
Merging usb-gadget-fixes/fixes (d8a4100ddc75 usb: gadget: udc: atmel: fix 
endpoint name)
Merging usb-serial-fixes/usb-linus (f190fd92458d USB: serial: simple: add 
support for another Infineon flashloader)
Merging usb-chipidea-fixes/ci-for-usb-stable (6f3c4fb6d05e usb: chipidea: udc: 
fix NULL ptr dereference in isr_setup_status_phase)
Merging staging.current/staging-linus (9395452b4aab Linux 4.8-rc6)
Merging char-misc.current/char-misc-linus (c6935931c189 Linux 4.8-rc5)
Merging input-current/for-linus (9fb6de1b0bf4 Input: joydev - recognize devices 
with Z axis as joysticks)
Merging crypto-current/master (80da44c29d99 crypto: vmx - Fix memory corruption 
caused by p8_ghash)
Merging ide/master (797cee982eef Merge branch 'stable-4.8' of 
git://git.infradead.org/users/pcmoore/audit)
Merging rr-fixes/fixes (8244062ef1e5 modules: fix longstanding /proc/kallsyms 
vs module insertion race.)
Merging vfio-fixes/for-linus 

linux-next: Tree for Oct 3

2016-10-02 Thread Stephen Rothwell
Hi all,

Changes since 20160930:

The net-next tree gained conflicts against Linus' tree.

The mac80211-next tree gained conflicts against Linus' tree.

The xen-tip tree gained conflicts againt the tip tree.

The tty tree lost its build failure.

Non-merge commits (relative to Linus' tree): 13450
 9993 files changed, 554934 insertions(+), 300943 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig (with
CONFIG_BUILD_DOCSRC=n) for x86_64, a multi_v7_defconfig for arm and a
native build of tools/perf. After the final fixups (if any), I do an
x86_64 modules_install followed by builds for x86_64 allnoconfig,
powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig
(this fails its final link) and pseries_le_defconfig and i386, sparc
and sparc64 defconfig.

Below is a summary of the state of the merge.

I am currently merging 243 trees (counting Linus' and 34 trees of patches
pending for Linus' tree).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (be67d60ba944 Merge branch 'x86-urgent-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip)
Merging fixes/master (d3396e1e4ec4 Merge tag 'fixes-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc)
Merging kbuild-current/rc-fixes (d3e2773c4ede builddeb: Skip gcc-plugins when 
not configured)
Merging arc-current/for-curr (3eab887a5542 Linux 4.8-rc4)
Merging arm-current/fixes (d248220f0465 ARM: 8617/1: dma: fix dma_max_pfn())
Merging m68k-current/for-linus (6bd80f372371 m68k/defconfig: Update defconfigs 
for v4.7-rc2)
Merging metag-fixes/fixes (97b1d23f7bcb metag: Drop show_mem() from mem_init())
Merging powerpc-fixes/fixes (b79331a5eb9f powerpc/powernv/pci: Fix m64 checks 
for SR-IOV and window alignment)
Merging sparc/master (2a0100d7beeb sparc64: Fix non-SMP build.)
Merging net/master (1cceda784980 sctp: fix the issue sctp_diag uses lock_sock 
in rcu_read_lock)
Merging ipsec/master (b1f2beb87bb0 Merge tag 'media/v4.8-7' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media)
Merging netfilter/master (440f895aa97f drivers: net: phy: xgene: Fix 'remove' 
function)
Merging ipvs/master (ea43f860d984 Merge branch 'ethoc-fixes')
Merging wireless-drivers/master (db64c5fa590b Merge tag 
'iwlwifi-for-kalle-2016-09-15' of 
git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes)
Merging mac80211/master (7ac327318e09 Merge tag 'mac80211-for-davem-2016-09-16' 
of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211)
Merging sound-current/for-linus (eeea8b40cd28 Merge tag 'asoc-v4.9' of 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next)
Merging pci-current/for-linus (035ee288ae7a PCI: Fix bridge_d3 update on device 
removal)
Merging driver-core.current/driver-core-linus (c6935931c189 Linux 4.8-rc5)
Merging tty.current/tty-linus (c6935931c189 Linux 4.8-rc5)
Merging usb.current/usb-linus (3be7988674ab Linux 4.8-rc7)
Merging usb-gadget-fixes/fixes (d8a4100ddc75 usb: gadget: udc: atmel: fix 
endpoint name)
Merging usb-serial-fixes/usb-linus (f190fd92458d USB: serial: simple: add 
support for another Infineon flashloader)
Merging usb-chipidea-fixes/ci-for-usb-stable (6f3c4fb6d05e usb: chipidea: udc: 
fix NULL ptr dereference in isr_setup_status_phase)
Merging staging.current/staging-linus (9395452b4aab Linux 4.8-rc6)
Merging char-misc.current/char-misc-linus (c6935931c189 Linux 4.8-rc5)
Merging input-current/for-linus (9fb6de1b0bf4 Input: joydev - recognize devices 
with Z axis as joysticks)
Merging crypto-current/master (80da44c29d99 crypto: vmx - Fix memory corruption 
caused by p8_ghash)
Merging ide/master (797cee982eef Merge branch 'stable-4.8' of 
git://git.infradead.org/users/pcmoore/audit)
Merging rr-fixes/fixes (8244062ef1e5 modules: fix longstanding /proc/kallsyms 
vs module insertion race.)
Merging vfio-fixes/for-linus 

Re: [PATCH] fs/block_dev.c: always return error in thaw_bdev()

2016-10-02 Thread Mateusz Guzik
On Thu, Aug 20, 2015 at 12:07:49PM +0200, Pierre Morel wrote:
> When triggering thaw-filesystems via magic sysrq, the system enters a
> loop in do_thaw_one(), as thaw_bdev() still returns success if
> bd_fsfreeze_count == 0. To fix this, let thaw_bdev() always return
> error (and simplify the code a bit at the same time).
> 
> Reviewed-by: Eric Farman 
> Reviewed-by: Cornelia Huck 
> Signed-off-by: Pierre Morel 
> ---
>  fs/block_dev.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index c7e4163..7809c92 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -269,14 +269,11 @@ int thaw_bdev(struct block_device *bdev, struct 
> super_block *sb)
>   error = sb->s_op->thaw_super(sb);
>   else
>   error = thaw_super(sb);
> - if (error) {
> + if (error)
>   bdev->bd_fsfreeze_count++;
> - mutex_unlock(>bd_fsfreeze_mutex);
> - return error;
> - }
>  out:
>   mutex_unlock(>bd_fsfreeze_mutex);
> - return 0;
> + return error;
>  }
>  EXPORT_SYMBOL(thaw_bdev);
>  

Apparently this never got in.

The bug is still there, reproducible with mere:
echo j > /proc/sysrq-trigger

-- 
Mateusz Guzik


Re: [PATCH] fs/block_dev.c: always return error in thaw_bdev()

2016-10-02 Thread Mateusz Guzik
On Thu, Aug 20, 2015 at 12:07:49PM +0200, Pierre Morel wrote:
> When triggering thaw-filesystems via magic sysrq, the system enters a
> loop in do_thaw_one(), as thaw_bdev() still returns success if
> bd_fsfreeze_count == 0. To fix this, let thaw_bdev() always return
> error (and simplify the code a bit at the same time).
> 
> Reviewed-by: Eric Farman 
> Reviewed-by: Cornelia Huck 
> Signed-off-by: Pierre Morel 
> ---
>  fs/block_dev.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index c7e4163..7809c92 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -269,14 +269,11 @@ int thaw_bdev(struct block_device *bdev, struct 
> super_block *sb)
>   error = sb->s_op->thaw_super(sb);
>   else
>   error = thaw_super(sb);
> - if (error) {
> + if (error)
>   bdev->bd_fsfreeze_count++;
> - mutex_unlock(>bd_fsfreeze_mutex);
> - return error;
> - }
>  out:
>   mutex_unlock(>bd_fsfreeze_mutex);
> - return 0;
> + return error;
>  }
>  EXPORT_SYMBOL(thaw_bdev);
>  

Apparently this never got in.

The bug is still there, reproducible with mere:
echo j > /proc/sysrq-trigger

-- 
Mateusz Guzik


Re: [PATCH V2 3/5] PCI: save and restore bus on parent bus reset

2016-10-02 Thread Sinan Kaya
On 9/29/2016 7:50 PM, Sinan Kaya wrote:
> Hi Bjorn,
> 
> On 9/29/2016 5:49 PM, Bjorn Helgaas wrote:
>>> +   }
>> This pattern of "unlock, do something, relock" needs some
>> justification.  In general it's unsafe because the lock is protecting
>> *something*, and you have to assume that something can change as soon
>> as you unlock.  Maybe you know it's safe in this situation, and if so,
>> the explanation of why it's safe is what I'm looking for.
> 
> Agreed. 
> 
> The problem is that save and restore routines obtain the lock again and
> they fails as the lock is already held.
> 
> The alternative is to change the dev_locks in save and restore to try_lock
> so that it will work if locks were previously obtained or not. 
> 
>>
>> Also, you're now calling pci_reset_bridge_secondary_bus() with the dev
>> unlocked, where we called it with the dev locked before.  Some (but
>> worryingly, not all) of the other pci_reset_bridge_secondary_bus()
>> callers also have the dev locked.  I didn't look long enough to figure
>> out if there is a strategy there or if these inconsistencies are
>> latent bugs.
>>
> 
> The goal of this routine is to reset the device not the bridge and the code
> will use FLR or others if available. Therefore, it makes perfect sense to
> obtain the device lock while doing this. 
> 
> The code tries to reset the bus if none of the other resets work. This is
> where the problem is. It destroys the context for other devices.
> 
> I can fix get rid of this unlock, do something and then lock again business
> by rewriting the locks in save and restore.
> 
> Sinan
> 

I looked at the code a little bit more. I missed the fact pci_parent_bus_reset
will only work if there is only PCI device on the bus and that device is the
reset requesting device.

I'll drop this patch as well as the infiniband version for the same reason.




-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux 
Foundation Collaborative Project.


Re: [PATCH V2 3/5] PCI: save and restore bus on parent bus reset

2016-10-02 Thread Sinan Kaya
On 9/29/2016 7:50 PM, Sinan Kaya wrote:
> Hi Bjorn,
> 
> On 9/29/2016 5:49 PM, Bjorn Helgaas wrote:
>>> +   }
>> This pattern of "unlock, do something, relock" needs some
>> justification.  In general it's unsafe because the lock is protecting
>> *something*, and you have to assume that something can change as soon
>> as you unlock.  Maybe you know it's safe in this situation, and if so,
>> the explanation of why it's safe is what I'm looking for.
> 
> Agreed. 
> 
> The problem is that save and restore routines obtain the lock again and
> they fails as the lock is already held.
> 
> The alternative is to change the dev_locks in save and restore to try_lock
> so that it will work if locks were previously obtained or not. 
> 
>>
>> Also, you're now calling pci_reset_bridge_secondary_bus() with the dev
>> unlocked, where we called it with the dev locked before.  Some (but
>> worryingly, not all) of the other pci_reset_bridge_secondary_bus()
>> callers also have the dev locked.  I didn't look long enough to figure
>> out if there is a strategy there or if these inconsistencies are
>> latent bugs.
>>
> 
> The goal of this routine is to reset the device not the bridge and the code
> will use FLR or others if available. Therefore, it makes perfect sense to
> obtain the device lock while doing this. 
> 
> The code tries to reset the bus if none of the other resets work. This is
> where the problem is. It destroys the context for other devices.
> 
> I can fix get rid of this unlock, do something and then lock again business
> by rewriting the locks in save and restore.
> 
> Sinan
> 

I looked at the code a little bit more. I missed the fact pci_parent_bus_reset
will only work if there is only PCI device on the bus and that device is the
reset requesting device.

I'll drop this patch as well as the infiniband version for the same reason.




-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux 
Foundation Collaborative Project.


Re: [PATCH V4 04/10] dmaengine: qcom_hidma: configure DMA and MSI for OF

2016-10-02 Thread Vinod Koul
On Sat, Oct 01, 2016 at 11:15:00AM -0400, Sinan Kaya wrote:
> On 10/1/2016 2:17 AM, Vinod Koul wrote:
> > On Wed, Sep 28, 2016 at 10:12:41PM -0400, Sinan Kaya wrote:
> >> Configure the DMA bindings for the device tree based firmware.
> >>
> >> Signed-off-by: Sinan Kaya 
> >> ---
> >>  drivers/dma/qcom/hidma_mgmt.c | 5 -
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c
> >> index 82f36e4..e8f6b84 100644
> >> --- a/drivers/dma/qcom/hidma_mgmt.c
> >> +++ b/drivers/dma/qcom/hidma_mgmt.c
> >> @@ -375,8 +375,11 @@ static int __init 
> >> hidma_mgmt_of_populate_channels(struct device_node *np)
> >>ret = PTR_ERR(new_pdev);
> >>goto out;
> >>}
> >> +  of_node_get(child);
> >> +  new_pdev->dev.of_node = child;
> >>of_dma_configure(_pdev->dev, child);
> >> -
> >> +  of_msi_configure(_pdev->dev, child);
> >> +  of_node_put(child);
> > 
> > should this be done unconditionally? Dont we needto call this only for
> > platforms with msi?
> 
> I followed the pattern in of_platform_device_create_pdata function. 
> of_msi_configure does
> nothing if MSI is not enabled as irq_find_matching_host returns NULL. It 
> didn't have any
> side effects on my testing either.

yeah later on I did look up the of_msi_configure() and I suspected this. I
think it would be worthwhile to document this assumption here.

Thanks
-- 
~Vinod


Re: [PATCH V4 04/10] dmaengine: qcom_hidma: configure DMA and MSI for OF

2016-10-02 Thread Vinod Koul
On Sat, Oct 01, 2016 at 11:15:00AM -0400, Sinan Kaya wrote:
> On 10/1/2016 2:17 AM, Vinod Koul wrote:
> > On Wed, Sep 28, 2016 at 10:12:41PM -0400, Sinan Kaya wrote:
> >> Configure the DMA bindings for the device tree based firmware.
> >>
> >> Signed-off-by: Sinan Kaya 
> >> ---
> >>  drivers/dma/qcom/hidma_mgmt.c | 5 -
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c
> >> index 82f36e4..e8f6b84 100644
> >> --- a/drivers/dma/qcom/hidma_mgmt.c
> >> +++ b/drivers/dma/qcom/hidma_mgmt.c
> >> @@ -375,8 +375,11 @@ static int __init 
> >> hidma_mgmt_of_populate_channels(struct device_node *np)
> >>ret = PTR_ERR(new_pdev);
> >>goto out;
> >>}
> >> +  of_node_get(child);
> >> +  new_pdev->dev.of_node = child;
> >>of_dma_configure(_pdev->dev, child);
> >> -
> >> +  of_msi_configure(_pdev->dev, child);
> >> +  of_node_put(child);
> > 
> > should this be done unconditionally? Dont we needto call this only for
> > platforms with msi?
> 
> I followed the pattern in of_platform_device_create_pdata function. 
> of_msi_configure does
> nothing if MSI is not enabled as irq_find_matching_host returns NULL. It 
> didn't have any
> side effects on my testing either.

yeah later on I did look up the of_msi_configure() and I suspected this. I
think it would be worthwhile to document this assumption here.

Thanks
-- 
~Vinod


Re: [PATCH V4 05/10] dmaengine: qcom_hidma: make pending_tre_count atomic

2016-10-02 Thread Vinod Koul
On Sat, Oct 01, 2016 at 11:19:43AM -0400, Sinan Kaya wrote:
> On 10/1/2016 2:19 AM, Vinod Koul wrote:
> >> Making it atomic so that it can be updated from multiple contexts.
> > How is it multiple contexts? It's either existing context of MSI, not both!
> > 
> 
> I was trying to mean multiple processor contexts here. The driver allocates 11
> MSI interrupts. Each MSI interrupt can be assigned to a different CPU. Then, 
> we have a race condition for common variables as they share the same interrupt
> handler with a different cause bit. 
> 
> I will put the above description into the commit text.

Sounds better :)

-- 
~Vinod


Re: [PATCH V4 05/10] dmaengine: qcom_hidma: make pending_tre_count atomic

2016-10-02 Thread Vinod Koul
On Sat, Oct 01, 2016 at 11:19:43AM -0400, Sinan Kaya wrote:
> On 10/1/2016 2:19 AM, Vinod Koul wrote:
> >> Making it atomic so that it can be updated from multiple contexts.
> > How is it multiple contexts? It's either existing context of MSI, not both!
> > 
> 
> I was trying to mean multiple processor contexts here. The driver allocates 11
> MSI interrupts. Each MSI interrupt can be assigned to a different CPU. Then, 
> we have a race condition for common variables as they share the same interrupt
> handler with a different cause bit. 
> 
> I will put the above description into the commit text.

Sounds better :)

-- 
~Vinod


[ANNOUNCE] BFS CPU scheduler v0.512 for linux-4.8, 4.8-ck1

2016-10-02 Thread Con Kolivas
This is to announce an updated stable version of the Brain Fuck Scheduler, 
version 0.512 for the current stable linux kernel for improved responsiveness 
and interactivity.

http://ck.kolivas.org/patches/bfs/4.0/4.8/4.8-sched-bfs-512.patch


A -ck branded release with minor tweaks and the addition of Jens' writeback 
throttling v7 (I'm watching the BFQ discussions with great interest at the 
moment) is also available as -ck1:

http://ck.kolivas.org/patches/4.0/4.8/4.8-ck1/patch-4.8-ck1.xz


Note that this may be the last BFS based -ck release as the Multiple Queue 
Skiplist Scheduler, MuQSS (pronounced mux) is designed to replace it, being 
the logical evolution of the same scheduler into a more scalable discrete 
runqueue design with an identical scheduling decision mechanism as BFS.

See introduction here:

http://ck-hack.blogspot.com/2016/10/muqss-multiple-queue-skiplist-scheduler.html


It is still immature and requires more testing and no doubt bug-fixes but is 
usable in its current form already - although lock debugging may be very 
unhappy for it does perverse things with locking. For those willing to try it 
in its current version, an incremental patch can be applied to BFS 512:

http://ck.kolivas.org/patches/muqss/4.0/4.8/bfs512-muqss104.patch


or there is a full patch against 4.8:

http://ck.kolivas.org/patches/muqss/4.0/4.8/4.8-sched-MuQSS_104.patch


Feedback and bug reports are most welcome, though bear in mind that it is 
(intentionally) extremely simple in its balancing design between CPUs in its 
current form and there may be workloads that benefit more from something like 
the complex balancing mechanism in mainline - although the opposite may also 
be true.


All patches available here:
http://ck.kolivas.org/patches

Code blog:
http://ck-hack.blogspot.com


Enjoy!
お楽しみ下さい

-- 
-ck



[ANNOUNCE] BFS CPU scheduler v0.512 for linux-4.8, 4.8-ck1

2016-10-02 Thread Con Kolivas
This is to announce an updated stable version of the Brain Fuck Scheduler, 
version 0.512 for the current stable linux kernel for improved responsiveness 
and interactivity.

http://ck.kolivas.org/patches/bfs/4.0/4.8/4.8-sched-bfs-512.patch


A -ck branded release with minor tweaks and the addition of Jens' writeback 
throttling v7 (I'm watching the BFQ discussions with great interest at the 
moment) is also available as -ck1:

http://ck.kolivas.org/patches/4.0/4.8/4.8-ck1/patch-4.8-ck1.xz


Note that this may be the last BFS based -ck release as the Multiple Queue 
Skiplist Scheduler, MuQSS (pronounced mux) is designed to replace it, being 
the logical evolution of the same scheduler into a more scalable discrete 
runqueue design with an identical scheduling decision mechanism as BFS.

See introduction here:

http://ck-hack.blogspot.com/2016/10/muqss-multiple-queue-skiplist-scheduler.html


It is still immature and requires more testing and no doubt bug-fixes but is 
usable in its current form already - although lock debugging may be very 
unhappy for it does perverse things with locking. For those willing to try it 
in its current version, an incremental patch can be applied to BFS 512:

http://ck.kolivas.org/patches/muqss/4.0/4.8/bfs512-muqss104.patch


or there is a full patch against 4.8:

http://ck.kolivas.org/patches/muqss/4.0/4.8/4.8-sched-MuQSS_104.patch


Feedback and bug reports are most welcome, though bear in mind that it is 
(intentionally) extremely simple in its balancing design between CPUs in its 
current form and there may be workloads that benefit more from something like 
the complex balancing mechanism in mainline - although the opposite may also 
be true.


All patches available here:
http://ck.kolivas.org/patches

Code blog:
http://ck-hack.blogspot.com


Enjoy!
お楽しみ下さい

-- 
-ck



Re: [RESEND PATCH v2 0/3] Broadcom AVS CPUfreq driver

2016-10-02 Thread Viresh Kumar
On 30-09-16, 14:55, Markus Mayer wrote:
> This series contains the CPUfreq driver for Broadcom SoCs that use "AVS
> Firmware" for voltage and frequency scaling. All voltage and frequency
> transitions are performed by the firmware and are therefore hidden from
> Linux.
> 
> The driver provides a standard CPUfreq interface to other kernel
> components and to userland on the one hand and communicates with the
> AVS co-processor on the other.
> 
> Communication between the two processors is via shared mailbox
> registers and interrupts (ARM -> AVS to tell the firmware that there is
> a command to process and AVS -> ARM to tell the driver that a command
> finished executing).
> 
> lkml.org seems to be down for me. Here are patchwork links to the original
> series:

My fault really. I wanted to review it earlier but couldn't :(

I should be doing it this week though.

-- 
viresh


Re: [RESEND PATCH v2 0/3] Broadcom AVS CPUfreq driver

2016-10-02 Thread Viresh Kumar
On 30-09-16, 14:55, Markus Mayer wrote:
> This series contains the CPUfreq driver for Broadcom SoCs that use "AVS
> Firmware" for voltage and frequency scaling. All voltage and frequency
> transitions are performed by the firmware and are therefore hidden from
> Linux.
> 
> The driver provides a standard CPUfreq interface to other kernel
> components and to userland on the one hand and communicates with the
> AVS co-processor on the other.
> 
> Communication between the two processors is via shared mailbox
> registers and interrupts (ARM -> AVS to tell the firmware that there is
> a command to process and AVS -> ARM to tell the driver that a command
> finished executing).
> 
> lkml.org seems to be down for me. Here are patchwork links to the original
> series:

My fault really. I wanted to review it earlier but couldn't :(

I should be doing it this week though.

-- 
viresh


Re: [PATCH] netfilter: bridge: clarify bridge/netfilter message

2016-10-02 Thread David Miller
From: Stefan Agner 
Date: Wed, 28 Sep 2016 15:05:28 -0700

> When using bridge without bridge netfilter enabled the message
> displayed is rather confusing and leads to belive that a deprecated
> feature is in use. Use IS_MODULE to be explicit that the message only
> affects users which use bridge netfilter as module and reword the
> message.
> 
> Signed-off-by: Stefan Agner 

Applied to net-next, thanks.


Re: [PATCH] netfilter: bridge: clarify bridge/netfilter message

2016-10-02 Thread David Miller
From: Stefan Agner 
Date: Wed, 28 Sep 2016 15:05:28 -0700

> When using bridge without bridge netfilter enabled the message
> displayed is rather confusing and leads to belive that a deprecated
> feature is in use. Use IS_MODULE to be explicit that the message only
> affects users which use bridge netfilter as module and reword the
> message.
> 
> Signed-off-by: Stefan Agner 

Applied to net-next, thanks.


Re: [PATCH v2 net-next 1/2] net: centralize net_device min/max MTU checking

2016-10-02 Thread David Miller
From: Jakub Sitnicki 
Date: Fri, 30 Sep 2016 11:37:24 +0200

> On Wed, Sep 28, 2016 at 10:20 PM GMT, Jarod Wilson wrote:
>> While looking into an MTU issue with sfc, I started noticing that almost
>> every NIC driver with an ndo_change_mtu function implemented almost
>> exactly the same range checks, and in many cases, that was the only
>> practical thing their ndo_change_mtu function was doing. Quite a few
>> drivers have either 68, 64, 60 or 46 as their minimum MTU value checked,
>> and then various sizes from 1500 to 65535 for their maximum MTU value. We
>> can remove a whole lot of redundant code here if we simple store min_mtu
>> and max_mtu in net_device, and check against those in net/core/dev.c's
>> dev_set_mtu().
>>
>> In theory, there should be zero functional change with this patch, it just
>> puts the infrastructure in place. Subsequent patches will attempt to start
>> using said infrastructure, with theoretically zero change in
>> functionality.
>>
>> CC: "David S. Miller" 
>> CC: net...@vger.kernel.org
>> Signed-off-by: Jarod Wilson 
>> ---
> 
> [...]
> 
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index c0c291f..5343799 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -6493,9 +6493,17 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
>>  if (new_mtu == dev->mtu)
>>  return 0;
>>  
>> -/*  MTU must be positive.*/
>> -if (new_mtu < 0)
>> +if (new_mtu < dev->min_mtu) {
> 
> Ouch, integral promotions. Looks like you need to keep the < 0 check.
> Otherwise new_mtu gets promoted to unsigned int and negative values will
> pass the check.

Agreed, the < 0 test must be reintroduced.


Re: [PATCH v2 net-next 1/2] net: centralize net_device min/max MTU checking

2016-10-02 Thread David Miller
From: Jakub Sitnicki 
Date: Fri, 30 Sep 2016 11:37:24 +0200

> On Wed, Sep 28, 2016 at 10:20 PM GMT, Jarod Wilson wrote:
>> While looking into an MTU issue with sfc, I started noticing that almost
>> every NIC driver with an ndo_change_mtu function implemented almost
>> exactly the same range checks, and in many cases, that was the only
>> practical thing their ndo_change_mtu function was doing. Quite a few
>> drivers have either 68, 64, 60 or 46 as their minimum MTU value checked,
>> and then various sizes from 1500 to 65535 for their maximum MTU value. We
>> can remove a whole lot of redundant code here if we simple store min_mtu
>> and max_mtu in net_device, and check against those in net/core/dev.c's
>> dev_set_mtu().
>>
>> In theory, there should be zero functional change with this patch, it just
>> puts the infrastructure in place. Subsequent patches will attempt to start
>> using said infrastructure, with theoretically zero change in
>> functionality.
>>
>> CC: "David S. Miller" 
>> CC: net...@vger.kernel.org
>> Signed-off-by: Jarod Wilson 
>> ---
> 
> [...]
> 
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index c0c291f..5343799 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -6493,9 +6493,17 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
>>  if (new_mtu == dev->mtu)
>>  return 0;
>>  
>> -/*  MTU must be positive.*/
>> -if (new_mtu < 0)
>> +if (new_mtu < dev->min_mtu) {
> 
> Ouch, integral promotions. Looks like you need to keep the < 0 check.
> Otherwise new_mtu gets promoted to unsigned int and negative values will
> pass the check.

Agreed, the < 0 test must be reintroduced.


[PATCH 20/41] staging: lustre: remove Size on MDS support

2016-10-02 Thread James Simmons
From: John L. Hammond 

Remove unused definitions related to Size on MDS support from
lustre/include/lustre/lustre_idl.h. Remove unused code from several
places in lustre/.

Signed-off-by: John L. Hammond 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6047
Reviewed-on: http://review.whamcloud.com/13443
Reviewed-by: Andreas Dilger 
Reviewed-by: Mike Pershin 
Signed-off-by: James Simmons 
---
 .../lustre/lustre/include/lustre/lustre_idl.h  |   41 ---
 .../lustre/lustre/include/lustre_req_layout.h  |1 -
 drivers/staging/lustre/lustre/include/obd.h|8 +++
 .../staging/lustre/lustre/include/obd_support.h|4 +-
 drivers/staging/lustre/lustre/mdc/mdc_lib.c|7 ++-
 drivers/staging/lustre/lustre/mdc/mdc_request.c|4 +-
 drivers/staging/lustre/lustre/ptlrpc/layout.c  |6 --
 .../staging/lustre/lustre/ptlrpc/pack_generic.c|7 ++-
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c|   58 ++--
 9 files changed, 46 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 4f6eeec..17feb71 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -310,7 +310,7 @@ static inline int range_compare_loc(const struct 
lu_seq_range *r1,
  */
 enum lma_compat {
LMAC_HSM= 0x0001,
-   LMAC_SOM= 0x0002,
+/* LMAC_SOM= 0x0002, obsolete since 2.8.0 */
LMAC_NOT_IN_OI  = 0x0004, /* the object does NOT need OI mapping */
LMAC_FID_ON_OST = 0x0008, /* For OST-object, its OI mapping is
   * under /O//d.
@@ -1923,7 +1923,7 @@ enum mds_cmd {
MDS_PIN = 42, /* obsolete, never used in a release */
MDS_UNPIN   = 43, /* obsolete, never used in a release */
MDS_SYNC= 44,
-   MDS_DONE_WRITING= 45,
+   MDS_DONE_WRITING= 45, /* obsolete since 2.8.0 */
MDS_SET_INFO= 46,
MDS_QUOTACHECK  = 47,
MDS_QUOTACTL= 48,
@@ -2021,24 +2021,6 @@ enum {
 #define MDS_STATUS_CONN 1
 #define MDS_STATUS_LOV 2
 
-/* mdt_thread_info.mti_flags. */
-enum md_op_flags {
-   /* The flag indicates Size-on-MDS attributes are changed. */
-   MF_SOM_CHANGE  = (1 << 0),
-   /* Flags indicates an epoch opens or closes. */
-   MF_EPOCH_OPEN  = (1 << 1),
-   MF_EPOCH_CLOSE= (1 << 2),
-   MF_MDC_CANCEL_FID1  = (1 << 3),
-   MF_MDC_CANCEL_FID2  = (1 << 4),
-   MF_MDC_CANCEL_FID3  = (1 << 5),
-   MF_MDC_CANCEL_FID4  = (1 << 6),
-   /* There is a pending attribute update. */
-   MF_SOM_AU  = (1 << 7),
-   /* Cancel OST locks while getattr OST attributes. */
-   MF_GETATTR_LOCK  = (1 << 8),
-   MF_GET_MDT_IDX= (1 << 9),
-};
-
 #define LUSTRE_BFLAG_UNCOMMITTED_WRITES   0x1
 
 /* these should be identical to their EXT4_*_FL counterparts, they are
@@ -2123,10 +2105,10 @@ struct mdt_body {
 void lustre_swab_mdt_body(struct mdt_body *b);
 
 struct mdt_ioepoch {
-   struct lustre_handle handle;
-   __u64  ioepoch;
-   __u32  flags;
-   __u32  padding;
+   struct lustre_handle mio_handle;
+   __u64 mio_unused1; /* was ioepoch */
+   __u32 mio_unused2; /* was flags */
+   __u32 mio_padding;
 };
 
 void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b);
@@ -2195,12 +2177,9 @@ void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr 
*sa);
 
 #define MDS_FMODE_CLOSED
 #define MDS_FMODE_EXEC0004
-/* IO Epoch is opened on a closed file. */
-#define MDS_FMODE_EPOCH  0100
-/* IO Epoch is opened on a file truncate. */
-#define MDS_FMODE_TRUNC  0200
-/* Size-on-MDS Attribute Update is pending. */
-#define MDS_FMODE_SOM  0400
+/* MDS_FMODE_EPOCH 0100 obsolete since 2.8.0 */
+/* MDS_FMODE_TRUNC 0200 obsolete since 2.8.0 */
+/* MDS_FMODE_SOM   0400 obsolete since 2.8.0 */
 
 #define MDS_OPEN_CREATED0010
 #define MDS_OPEN_CROSS0020
@@ -2246,7 +2225,7 @@ enum mds_op_bias {
MDS_CROSS_REF   = 1 << 1,
MDS_VTX_BYPASS  = 1 << 2,
MDS_PERM_BYPASS = 1 << 3,
-   MDS_SOM = 1 << 4,
+/* MDS_SOM = 1 << 4, obsolete since 2.8.0 */
MDS_QUOTA_IGNORE= 1 << 5,
MDS_CLOSE_CLEANUP   = 1 << 6,
MDS_KEEP_ORPHAN = 1 << 7,
diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h 
b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
index a13558e..dd8717e 100644
--- 

[PATCH 03/41] staging: lustre: llite: remove client Size on MDS support

2016-10-02 Thread James Simmons
From: John L. Hammond 

Size on MDS support have been in preview since at least 2.0.0. Remove
support for it from lustre/llite/.

Signed-off-by: John L. Hammond 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6047
Reviewed-on: http://review.whamcloud.com/13126
Reviewed-by: Andreas Dilger 
Reviewed-by: Lai Siyao 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/llite/Makefile   |2 +-
 drivers/staging/lustre/lustre/llite/file.c |   97 +-
 drivers/staging/lustre/lustre/llite/glimpse.c  |  105 +++---
 drivers/staging/lustre/lustre/llite/llite_close.c  |  395 
 .../staging/lustre/lustre/llite/llite_internal.h   |   56 +---
 drivers/staging/lustre/lustre/llite/llite_lib.c|  127 +--
 drivers/staging/lustre/lustre/llite/namei.c|8 -
 drivers/staging/lustre/lustre/llite/vvp_dev.c  |3 +-
 drivers/staging/lustre/lustre/llite/vvp_internal.h |   18 +-
 drivers/staging/lustre/lustre/llite/vvp_io.c   |   11 -
 drivers/staging/lustre/lustre/llite/vvp_object.c   |4 +-
 drivers/staging/lustre/lustre/llite/vvp_page.c |   24 +--
 drivers/staging/lustre/lustre/llite/vvp_req.c  |   13 +-
 13 files changed, 89 insertions(+), 774 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/llite/llite_close.c

diff --git a/drivers/staging/lustre/lustre/llite/Makefile 
b/drivers/staging/lustre/lustre/llite/Makefile
index 1ac0940..3690bee 100644
--- a/drivers/staging/lustre/lustre/llite/Makefile
+++ b/drivers/staging/lustre/lustre/llite/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_LUSTRE_FS) += lustre.o
-lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \
+lustre-y := dcache.o dir.o file.o llite_lib.o llite_nfs.o \
rw.o namei.o symlink.o llite_mmap.o range_lock.o \
xattr.o xattr_cache.o rw26.o super25.o statahead.o \
glimpse.o lcommon_cl.o lcommon_misc.o \
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 6e3a188..b2058c6 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -86,7 +86,6 @@ void ll_pack_inode2opdata(struct inode *inode, struct 
md_op_data *op_data,
op_data->op_attr.ia_size = i_size_read(inode);
op_data->op_attr_blocks = inode->i_blocks;
op_data->op_attr_flags = ll_inode_to_ext_flags(inode->i_flags);
-   op_data->op_ioepoch = ll_i2info(inode)->lli_ioepoch;
if (fh)
op_data->op_handle = *fh;
 
@@ -95,8 +94,7 @@ void ll_pack_inode2opdata(struct inode *inode, struct 
md_op_data *op_data,
 }
 
 /**
- * Closes the IO epoch and packs all the attributes into @op_data for
- * the CLOSE rpc.
+ * Packs all the attributes into @op_data for the CLOSE rpc.
  */
 static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data,
 struct obd_client_handle *och)
@@ -108,11 +106,7 @@ static void ll_prepare_close(struct inode *inode, struct 
md_op_data *op_data,
if (!(och->och_flags & FMODE_WRITE))
goto out;
 
-   if (!exp_connect_som(ll_i2mdexp(inode)) || !S_ISREG(inode->i_mode))
-   op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS;
-   else
-   ll_ioepoch_close(inode, op_data, , 0);
-
+   op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS;
 out:
ll_pack_inode2opdata(inode, op_data, >och_fh);
ll_prep_md_op_data(op_data, inode, NULL, NULL,
@@ -128,7 +122,6 @@ static int ll_close_inode_openhandle(struct obd_export 
*md_exp,
struct md_op_data *op_data;
struct ptlrpc_request *req = NULL;
struct obd_device *obd = class_exp2obd(exp);
-   int epoch_close = 1;
int rc;
 
if (!obd) {
@@ -157,22 +150,9 @@ static int ll_close_inode_openhandle(struct obd_export 
*md_exp,
op_data->op_lease_handle = och->och_lease_handle;
op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS;
}
-   epoch_close = op_data->op_flags & MF_EPOCH_CLOSE;
+
rc = md_close(md_exp, op_data, och->och_mod, );
-   if (rc == -EAGAIN) {
-   /* This close must have the epoch closed. */
-   LASSERT(epoch_close);
-   /* MDS has instructed us to obtain Size-on-MDS attribute from
-* OSTs and send setattr to back to MDS.
-*/
-   rc = ll_som_update(inode, op_data);
-   if (rc) {
-   CERROR("%s: inode "DFID" mdc Size-on-MDS update failed: 
rc = %d\n",
-  ll_i2mdexp(inode)->exp_obd->obd_name,
-  PFID(ll_inode2fid(inode)), rc);
-   rc = 0;
-   }
-   } else if (rc) {
+   if (rc) {
   

[PATCH 22/41] staging: lustre: obd: remove unused LSM parameters

2016-10-02 Thread James Simmons
From: John L. Hammond 

Remove unused struct lov_stripe_md * parameters from obd_get_info(),
mgc_enqueue(), and osc_brw_prep_request().

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13426
Reviewed-by: Andreas Dilger 
Reviewed-by: Lai Siyao 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|3 +--
 drivers/staging/lustre/lustre/include/obd_class.h  |6 ++
 drivers/staging/lustre/lustre/llite/dir.c  |2 +-
 drivers/staging/lustre/lustre/llite/lcommon_misc.c |2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|6 +++---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|8 +++-
 drivers/staging/lustre/lustre/lov/lov_obd.c|3 +--
 drivers/staging/lustre/lustre/mdc/mdc_request.c|5 ++---
 drivers/staging/lustre/lustre/mgc/mgc_request.c|9 -
 drivers/staging/lustre/lustre/obdclass/obd_mount.c |2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|7 ++-
 11 files changed, 21 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 5c31376..c72a1e1 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -845,8 +845,7 @@ struct obd_ops {
int (*iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
 void *karg, void __user *uarg);
int (*get_info)(const struct lu_env *env, struct obd_export *,
-   __u32 keylen, void *key, __u32 *vallen, void *val,
-   struct lov_stripe_md *lsm);
+   __u32 keylen, void *key, __u32 *vallen, void *val);
int (*set_info_async)(const struct lu_env *, struct obd_export *,
  __u32 keylen, void *key,
  __u32 vallen, void *val,
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index b2ced8b..7a5d75a 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -415,16 +415,14 @@ static inline int class_devno_max(void)
 
 static inline int obd_get_info(const struct lu_env *env,
   struct obd_export *exp, __u32 keylen,
-  void *key, __u32 *vallen, void *val,
-  struct lov_stripe_md *lsm)
+  void *key, __u32 *vallen, void *val)
 {
int rc;
 
EXP_CHECK_DT_OP(exp, get_info);
EXP_COUNTER_INCREMENT(exp, get_info);
 
-   rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val,
-lsm);
+   rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val);
return rc;
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/dir.c 
b/drivers/staging/lustre/lustre/llite/dir.c
index 68675eb..12e9a38 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1535,7 +1535,7 @@ out_quotactl:
exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp;
vallen = sizeof(count);
rc = obd_get_info(NULL, exp, sizeof(KEY_TGT_COUNT),
- KEY_TGT_COUNT, , , NULL);
+ KEY_TGT_COUNT, , );
if (rc) {
CERROR("get target count failed: %d\n", rc);
return rc;
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c 
b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
index fb346c1..07d38e5 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
@@ -54,7 +54,7 @@ int cl_init_ea_size(struct obd_export *md_exp, struct 
obd_export *dt_exp)
__u16 stripes, def_stripes;
 
rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC,
- , , NULL);
+ , );
if (rc)
return rc;
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 9112a52..6270301 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -285,7 +285,7 @@ static int client_common_fill_super(struct super_block *sb, 
char *md, char *dt,
 
size = sizeof(*data);
err = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_CONN_DATA),
-  KEY_CONN_DATA,  , 

[PATCH 20/41] staging: lustre: remove Size on MDS support

2016-10-02 Thread James Simmons
From: John L. Hammond 

Remove unused definitions related to Size on MDS support from
lustre/include/lustre/lustre_idl.h. Remove unused code from several
places in lustre/.

Signed-off-by: John L. Hammond 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6047
Reviewed-on: http://review.whamcloud.com/13443
Reviewed-by: Andreas Dilger 
Reviewed-by: Mike Pershin 
Signed-off-by: James Simmons 
---
 .../lustre/lustre/include/lustre/lustre_idl.h  |   41 ---
 .../lustre/lustre/include/lustre_req_layout.h  |1 -
 drivers/staging/lustre/lustre/include/obd.h|8 +++
 .../staging/lustre/lustre/include/obd_support.h|4 +-
 drivers/staging/lustre/lustre/mdc/mdc_lib.c|7 ++-
 drivers/staging/lustre/lustre/mdc/mdc_request.c|4 +-
 drivers/staging/lustre/lustre/ptlrpc/layout.c  |6 --
 .../staging/lustre/lustre/ptlrpc/pack_generic.c|7 ++-
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c|   58 ++--
 9 files changed, 46 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 4f6eeec..17feb71 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -310,7 +310,7 @@ static inline int range_compare_loc(const struct 
lu_seq_range *r1,
  */
 enum lma_compat {
LMAC_HSM= 0x0001,
-   LMAC_SOM= 0x0002,
+/* LMAC_SOM= 0x0002, obsolete since 2.8.0 */
LMAC_NOT_IN_OI  = 0x0004, /* the object does NOT need OI mapping */
LMAC_FID_ON_OST = 0x0008, /* For OST-object, its OI mapping is
   * under /O//d.
@@ -1923,7 +1923,7 @@ enum mds_cmd {
MDS_PIN = 42, /* obsolete, never used in a release */
MDS_UNPIN   = 43, /* obsolete, never used in a release */
MDS_SYNC= 44,
-   MDS_DONE_WRITING= 45,
+   MDS_DONE_WRITING= 45, /* obsolete since 2.8.0 */
MDS_SET_INFO= 46,
MDS_QUOTACHECK  = 47,
MDS_QUOTACTL= 48,
@@ -2021,24 +2021,6 @@ enum {
 #define MDS_STATUS_CONN 1
 #define MDS_STATUS_LOV 2
 
-/* mdt_thread_info.mti_flags. */
-enum md_op_flags {
-   /* The flag indicates Size-on-MDS attributes are changed. */
-   MF_SOM_CHANGE  = (1 << 0),
-   /* Flags indicates an epoch opens or closes. */
-   MF_EPOCH_OPEN  = (1 << 1),
-   MF_EPOCH_CLOSE= (1 << 2),
-   MF_MDC_CANCEL_FID1  = (1 << 3),
-   MF_MDC_CANCEL_FID2  = (1 << 4),
-   MF_MDC_CANCEL_FID3  = (1 << 5),
-   MF_MDC_CANCEL_FID4  = (1 << 6),
-   /* There is a pending attribute update. */
-   MF_SOM_AU  = (1 << 7),
-   /* Cancel OST locks while getattr OST attributes. */
-   MF_GETATTR_LOCK  = (1 << 8),
-   MF_GET_MDT_IDX= (1 << 9),
-};
-
 #define LUSTRE_BFLAG_UNCOMMITTED_WRITES   0x1
 
 /* these should be identical to their EXT4_*_FL counterparts, they are
@@ -2123,10 +2105,10 @@ struct mdt_body {
 void lustre_swab_mdt_body(struct mdt_body *b);
 
 struct mdt_ioepoch {
-   struct lustre_handle handle;
-   __u64  ioepoch;
-   __u32  flags;
-   __u32  padding;
+   struct lustre_handle mio_handle;
+   __u64 mio_unused1; /* was ioepoch */
+   __u32 mio_unused2; /* was flags */
+   __u32 mio_padding;
 };
 
 void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b);
@@ -2195,12 +2177,9 @@ void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr 
*sa);
 
 #define MDS_FMODE_CLOSED
 #define MDS_FMODE_EXEC0004
-/* IO Epoch is opened on a closed file. */
-#define MDS_FMODE_EPOCH  0100
-/* IO Epoch is opened on a file truncate. */
-#define MDS_FMODE_TRUNC  0200
-/* Size-on-MDS Attribute Update is pending. */
-#define MDS_FMODE_SOM  0400
+/* MDS_FMODE_EPOCH 0100 obsolete since 2.8.0 */
+/* MDS_FMODE_TRUNC 0200 obsolete since 2.8.0 */
+/* MDS_FMODE_SOM   0400 obsolete since 2.8.0 */
 
 #define MDS_OPEN_CREATED0010
 #define MDS_OPEN_CROSS0020
@@ -2246,7 +2225,7 @@ enum mds_op_bias {
MDS_CROSS_REF   = 1 << 1,
MDS_VTX_BYPASS  = 1 << 2,
MDS_PERM_BYPASS = 1 << 3,
-   MDS_SOM = 1 << 4,
+/* MDS_SOM = 1 << 4, obsolete since 2.8.0 */
MDS_QUOTA_IGNORE= 1 << 5,
MDS_CLOSE_CLEANUP   = 1 << 6,
MDS_KEEP_ORPHAN = 1 << 7,
diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h 
b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
index a13558e..dd8717e 100644
--- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h
+++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
@@ -154,7 

[PATCH 03/41] staging: lustre: llite: remove client Size on MDS support

2016-10-02 Thread James Simmons
From: John L. Hammond 

Size on MDS support have been in preview since at least 2.0.0. Remove
support for it from lustre/llite/.

Signed-off-by: John L. Hammond 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6047
Reviewed-on: http://review.whamcloud.com/13126
Reviewed-by: Andreas Dilger 
Reviewed-by: Lai Siyao 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/llite/Makefile   |2 +-
 drivers/staging/lustre/lustre/llite/file.c |   97 +-
 drivers/staging/lustre/lustre/llite/glimpse.c  |  105 +++---
 drivers/staging/lustre/lustre/llite/llite_close.c  |  395 
 .../staging/lustre/lustre/llite/llite_internal.h   |   56 +---
 drivers/staging/lustre/lustre/llite/llite_lib.c|  127 +--
 drivers/staging/lustre/lustre/llite/namei.c|8 -
 drivers/staging/lustre/lustre/llite/vvp_dev.c  |3 +-
 drivers/staging/lustre/lustre/llite/vvp_internal.h |   18 +-
 drivers/staging/lustre/lustre/llite/vvp_io.c   |   11 -
 drivers/staging/lustre/lustre/llite/vvp_object.c   |4 +-
 drivers/staging/lustre/lustre/llite/vvp_page.c |   24 +--
 drivers/staging/lustre/lustre/llite/vvp_req.c  |   13 +-
 13 files changed, 89 insertions(+), 774 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/llite/llite_close.c

diff --git a/drivers/staging/lustre/lustre/llite/Makefile 
b/drivers/staging/lustre/lustre/llite/Makefile
index 1ac0940..3690bee 100644
--- a/drivers/staging/lustre/lustre/llite/Makefile
+++ b/drivers/staging/lustre/lustre/llite/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_LUSTRE_FS) += lustre.o
-lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \
+lustre-y := dcache.o dir.o file.o llite_lib.o llite_nfs.o \
rw.o namei.o symlink.o llite_mmap.o range_lock.o \
xattr.o xattr_cache.o rw26.o super25.o statahead.o \
glimpse.o lcommon_cl.o lcommon_misc.o \
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 6e3a188..b2058c6 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -86,7 +86,6 @@ void ll_pack_inode2opdata(struct inode *inode, struct 
md_op_data *op_data,
op_data->op_attr.ia_size = i_size_read(inode);
op_data->op_attr_blocks = inode->i_blocks;
op_data->op_attr_flags = ll_inode_to_ext_flags(inode->i_flags);
-   op_data->op_ioepoch = ll_i2info(inode)->lli_ioepoch;
if (fh)
op_data->op_handle = *fh;
 
@@ -95,8 +94,7 @@ void ll_pack_inode2opdata(struct inode *inode, struct 
md_op_data *op_data,
 }
 
 /**
- * Closes the IO epoch and packs all the attributes into @op_data for
- * the CLOSE rpc.
+ * Packs all the attributes into @op_data for the CLOSE rpc.
  */
 static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data,
 struct obd_client_handle *och)
@@ -108,11 +106,7 @@ static void ll_prepare_close(struct inode *inode, struct 
md_op_data *op_data,
if (!(och->och_flags & FMODE_WRITE))
goto out;
 
-   if (!exp_connect_som(ll_i2mdexp(inode)) || !S_ISREG(inode->i_mode))
-   op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS;
-   else
-   ll_ioepoch_close(inode, op_data, , 0);
-
+   op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS;
 out:
ll_pack_inode2opdata(inode, op_data, >och_fh);
ll_prep_md_op_data(op_data, inode, NULL, NULL,
@@ -128,7 +122,6 @@ static int ll_close_inode_openhandle(struct obd_export 
*md_exp,
struct md_op_data *op_data;
struct ptlrpc_request *req = NULL;
struct obd_device *obd = class_exp2obd(exp);
-   int epoch_close = 1;
int rc;
 
if (!obd) {
@@ -157,22 +150,9 @@ static int ll_close_inode_openhandle(struct obd_export 
*md_exp,
op_data->op_lease_handle = och->och_lease_handle;
op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS;
}
-   epoch_close = op_data->op_flags & MF_EPOCH_CLOSE;
+
rc = md_close(md_exp, op_data, och->och_mod, );
-   if (rc == -EAGAIN) {
-   /* This close must have the epoch closed. */
-   LASSERT(epoch_close);
-   /* MDS has instructed us to obtain Size-on-MDS attribute from
-* OSTs and send setattr to back to MDS.
-*/
-   rc = ll_som_update(inode, op_data);
-   if (rc) {
-   CERROR("%s: inode "DFID" mdc Size-on-MDS update failed: 
rc = %d\n",
-  ll_i2mdexp(inode)->exp_obd->obd_name,
-  PFID(ll_inode2fid(inode)), rc);
-   rc = 0;
-   }
-   } else if (rc) {
+   if (rc) {
CERROR("%s: inode "DFID" mdc close failed: rc = %d\n",
   ll_i2mdexp(inode)->exp_obd->obd_name,
 

[PATCH 22/41] staging: lustre: obd: remove unused LSM parameters

2016-10-02 Thread James Simmons
From: John L. Hammond 

Remove unused struct lov_stripe_md * parameters from obd_get_info(),
mgc_enqueue(), and osc_brw_prep_request().

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13426
Reviewed-by: Andreas Dilger 
Reviewed-by: Lai Siyao 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|3 +--
 drivers/staging/lustre/lustre/include/obd_class.h  |6 ++
 drivers/staging/lustre/lustre/llite/dir.c  |2 +-
 drivers/staging/lustre/lustre/llite/lcommon_misc.c |2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|6 +++---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|8 +++-
 drivers/staging/lustre/lustre/lov/lov_obd.c|3 +--
 drivers/staging/lustre/lustre/mdc/mdc_request.c|5 ++---
 drivers/staging/lustre/lustre/mgc/mgc_request.c|9 -
 drivers/staging/lustre/lustre/obdclass/obd_mount.c |2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|7 ++-
 11 files changed, 21 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 5c31376..c72a1e1 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -845,8 +845,7 @@ struct obd_ops {
int (*iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
 void *karg, void __user *uarg);
int (*get_info)(const struct lu_env *env, struct obd_export *,
-   __u32 keylen, void *key, __u32 *vallen, void *val,
-   struct lov_stripe_md *lsm);
+   __u32 keylen, void *key, __u32 *vallen, void *val);
int (*set_info_async)(const struct lu_env *, struct obd_export *,
  __u32 keylen, void *key,
  __u32 vallen, void *val,
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index b2ced8b..7a5d75a 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -415,16 +415,14 @@ static inline int class_devno_max(void)
 
 static inline int obd_get_info(const struct lu_env *env,
   struct obd_export *exp, __u32 keylen,
-  void *key, __u32 *vallen, void *val,
-  struct lov_stripe_md *lsm)
+  void *key, __u32 *vallen, void *val)
 {
int rc;
 
EXP_CHECK_DT_OP(exp, get_info);
EXP_COUNTER_INCREMENT(exp, get_info);
 
-   rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val,
-lsm);
+   rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val);
return rc;
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/dir.c 
b/drivers/staging/lustre/lustre/llite/dir.c
index 68675eb..12e9a38 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1535,7 +1535,7 @@ out_quotactl:
exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp;
vallen = sizeof(count);
rc = obd_get_info(NULL, exp, sizeof(KEY_TGT_COUNT),
- KEY_TGT_COUNT, , , NULL);
+ KEY_TGT_COUNT, , );
if (rc) {
CERROR("get target count failed: %d\n", rc);
return rc;
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c 
b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
index fb346c1..07d38e5 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
@@ -54,7 +54,7 @@ int cl_init_ea_size(struct obd_export *md_exp, struct 
obd_export *dt_exp)
__u16 stripes, def_stripes;
 
rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC,
- , , NULL);
+ , );
if (rc)
return rc;
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 9112a52..6270301 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -285,7 +285,7 @@ static int client_common_fill_super(struct super_block *sb, 
char *md, char *dt,
 
size = sizeof(*data);
err = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_CONN_DATA),
-  KEY_CONN_DATA,  , data, NULL);
+  KEY_CONN_DATA,  , data);
if (err) {
CERROR("%s: Get connect data failed: rc = %d\n",
   

[PATCH 06/41] staging: lustre: ldlm: remove unnecessary EXPORT_SYMBOL

2016-10-02 Thread James Simmons
From: frank zago 

A lot of symbols don't need to be exported at all because they are
only used in the module they belong to.

Signed-off-by: frank zago 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5829
Reviewed-on: http://review.whamcloud.com/13324
Reviewed-by: James Simmons 
Reviewed-by: John L. Hammond 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |3 ---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|2 --
 drivers/staging/lustre/lustre/ldlm/ldlm_pool.c |6 --
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |3 ---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |4 
 5 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 3c48b4f..ace8cb2 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -512,7 +512,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, 
struct ldlm_lock *lock,
 
return 0;
 }
-EXPORT_SYMBOL(ldlm_lock_change_resource);
 
 /** \defgroup ldlm_handles LDLM HANDLES
  * Ways to get hold of locks without any addresses.
@@ -595,7 +594,6 @@ void ldlm_lock2desc(struct ldlm_lock *lock, struct 
ldlm_lock_desc *desc)
>l_policy_data,
>l_policy_data);
 }
-EXPORT_SYMBOL(ldlm_lock2desc);
 
 /**
  * Add a lock to list of conflicting locks to send AST to.
@@ -1147,7 +1145,6 @@ void ldlm_lock_fail_match_locked(struct ldlm_lock *lock)
wake_up_all(>l_waitq);
}
 }
-EXPORT_SYMBOL(ldlm_lock_fail_match_locked);
 
 /**
  * Mark lock as "matchable" by OST.
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index fde697e..c32b414 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -858,7 +858,6 @@ int ldlm_get_ref(void)
 
return rc;
 }
-EXPORT_SYMBOL(ldlm_get_ref);
 
 void ldlm_put_ref(void)
 {
@@ -875,7 +874,6 @@ void ldlm_put_ref(void)
}
mutex_unlock(_ref_mutex);
 }
-EXPORT_SYMBOL(ldlm_put_ref);
 
 static ssize_t cancel_unused_locks_before_replay_show(struct kobject *kobj,
  struct attribute *attr,
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index 9a1136e..b29c956 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -684,7 +684,6 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct 
ldlm_namespace *ns,
 
return rc;
 }
-EXPORT_SYMBOL(ldlm_pool_init);
 
 void ldlm_pool_fini(struct ldlm_pool *pl)
 {
@@ -698,7 +697,6 @@ void ldlm_pool_fini(struct ldlm_pool *pl)
 */
POISON(pl, 0x5a, sizeof(*pl));
 }
-EXPORT_SYMBOL(ldlm_pool_fini);
 
 /**
  * Add new taken ldlm lock \a lock into pool \a pl accounting.
@@ -724,7 +722,6 @@ void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock 
*lock)
 * with too long call paths.
 */
 }
-EXPORT_SYMBOL(ldlm_pool_add);
 
 /**
  * Remove ldlm lock \a lock from pool \a pl accounting.
@@ -743,7 +740,6 @@ void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock 
*lock)
 
lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_CANCEL_STAT);
 }
-EXPORT_SYMBOL(ldlm_pool_del);
 
 /**
  * Returns current \a pl SLV.
@@ -1095,7 +1091,6 @@ int ldlm_pools_init(void)
 
return rc;
 }
-EXPORT_SYMBOL(ldlm_pools_init);
 
 void ldlm_pools_fini(void)
 {
@@ -1104,4 +1099,3 @@ void ldlm_pools_fini(void)
 
ldlm_pools_thread_stop();
 }
-EXPORT_SYMBOL(ldlm_pools_fini);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 35ba6f1..98730a3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1022,7 +1022,6 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req)
 
return 0;
 }
-EXPORT_SYMBOL(ldlm_cli_update_pool);
 
 /**
  * Client side lock cancel.
@@ -1125,7 +1124,6 @@ int ldlm_cli_cancel_list_local(struct list_head *cancels, 
int count,
 
return count;
 }
-EXPORT_SYMBOL(ldlm_cli_cancel_list_local);
 
 /**
  * Cancel as many locks as possible w/o sending any RPCs (e.g. to write back
@@ -2048,4 +2046,3 @@ int ldlm_replay_locks(struct obd_import *imp)
 
return rc;
 }
-EXPORT_SYMBOL(ldlm_replay_locks);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index a09c25a..07cb955 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c

[PATCH 11/41] staging: lustre: ptlrpc: Add OBD_CONNECT_MULTIMODRPCS flag

2016-10-02 Thread James Simmons
From: Gregoire Pichon 

The new OBD_CONNECT_MULTIMODRPCS connection flag indicates the support
of multiple modify RPCs in parallel. It can be specified by the client
within the connection request and by the server within the connection
reply. The new ocd_maxmodrpcs connection data specifies the maximum modify
RPCs in parallel supported by the server.

To allow the MDS to send the new ocd_maxmodrpcs field, it has been
required to modify RMF_CONNECT_DATA so that its size includes the new
field. This change leads to remove the ocd_connect_data_v1 structure.
Note that the client has been allocating an extra 16*sizeof(__u64) for
the obd_connect_data reply since 2.0 and even in later versions of 1.8)
so there is no problem for the MDS to just send the full reply size.

This patch fixes a bug in __req_capsule_get() since it wasn't checking
RMF_F_NO_SIZE_CHECK when receiving the message. This allows legacy
clients (with version lower that this commit) to send connection
request with ocd_connect_data structure size smaller (actually size is
ocd_connect_data_v1 structure size) than new server ocd_connect_data
structure size.

This patch also fixes a bug in the routine that displays the import's
connect data.

Signed-off-by: Gregoire Pichon 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5319
Reviewed-on: http://review.whamcloud.com/#/c/13960
Reviewed-by: Andreas Dilger 
Reviewed-by: Alex Zhuravlev 
Signed-off-by: James Simmons 
---
 .../lustre/lustre/include/lustre/lustre_idl.h  |   26 ---
 .../lustre/lustre/obdclass/lprocfs_status.c|7 -
 drivers/staging/lustre/lustre/ptlrpc/layout.c  |5 ++-
 .../staging/lustre/lustre/ptlrpc/pack_generic.c|3 ++
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c|   14 +-
 5 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 4210716..b88807f 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -1282,6 +1282,9 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 */
 #define OBD_CONNECT_LFSCK  0x40ULL/* support online LFSCK */
 #define OBD_CONNECT_UNLINK_CLOSE 0x100ULL/* close file in unlink */
+#define OBD_CONNECT_MULTIMODRPCS 0x200ULL /* support multiple 
modify
+  *  RPCs in parallel
+  */
 #define OBD_CONNECT_DIR_STRIPE  0x400ULL/* striped DNE dir */
 
 /* XXX README XXX:
@@ -1313,25 +1316,6 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
  * If we eventually have separate connect data for different types, which we
  * almost certainly will, then perhaps we stick a union in here.
  */
-struct obd_connect_data_v1 {
-   __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
-   __u32 ocd_version;   /* lustre release version number */
-   __u32 ocd_grant; /* initial cache grant amount (bytes) */
-   __u32 ocd_index; /* LOV index to connect to */
-   __u32 ocd_brw_size;  /* Maximum BRW size in bytes, must be 2^n */
-   __u64 ocd_ibits_known;   /* inode bits this client understands */
-   __u8  ocd_blocksize; /* log2 of the backend filesystem blocksize */
-   __u8  ocd_inodespace;/* log2 of the per-inode space consumption */
-   __u16 ocd_grant_extent;  /* per-extent grant overhead, in 1K blocks */
-   __u32 ocd_unused;   /* also fix lustre_swab_connect */
-   __u64 ocd_transno;   /* first transno from client to be replayed */
-   __u32 ocd_group; /* MDS group on OST */
-   __u32 ocd_cksum_types;   /* supported checksum algorithms */
-   __u32 ocd_max_easize;/* How big LOV EA can be on MDS */
-   __u32 ocd_instance;  /* also fix lustre_swab_connect */
-   __u64 ocd_maxbytes;  /* Maximum stripe size in bytes */
-};
-
 struct obd_connect_data {
__u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
__u32 ocd_version;   /* lustre release version number */
@@ -1354,7 +1338,9 @@ struct obd_connect_data {
 * any field after ocd_maxbytes on the receiver without a valid flag
 * may result in out-of-bound memory access and kernel oops.
 */
-   __u64 padding1;   /* added 2.1.0. also fix lustre_swab_connect */
+   __u16 ocd_maxmodrpcs;   /* Maximum modify RPCs in parallel */
+   __u16 padding0; /* added 2.1.0. also fix lustre_swab_connect */
+   __u32 padding1; /* added 2.1.0. also fix lustre_swab_connect */
__u64 padding2;   /* added 2.1.0. also fix 

[PATCH 14/41] staging: lustre: ptlrpc: Add a tag field to ptlrpc messages

2016-10-02 Thread James Simmons
From: Gregoire Pichon 

The new tag field is used as a virtual index for multiple modifying
RPCs management. It is set by the client and allows the target to
release in-memory reply data when the tag is reused by a new RPC.

The tag field replaces the unused last_seen field of ptlrpcd_body
structure.

Additionally, the last_xid field is used to transfer the highest XID
for which a reply has been received and does not have an unreplied
lower-numbered XID.

Signed-off-by: Gregoire Pichon 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5319
Reviewed-on: http://review.whamcloud.com/14095
Reviewed-by: Andreas Dilger 
Reviewed-by: Alex Zhuravlev 
Signed-off-by: James Simmons 
---
 .../lustre/lustre/include/lustre/lustre_idl.h  |   12 --
 drivers/staging/lustre/lustre/include/lustre_net.h |2 +
 .../staging/lustre/lustre/ptlrpc/pack_generic.c|   39 +++-
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c|   32 
 4 files changed, 72 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index b88807f..4f6eeec 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -1099,8 +1099,10 @@ struct ptlrpc_body_v3 {
__u32 pb_version;
__u32 pb_opc;
__u32 pb_status;
-   __u64 pb_last_xid;
-   __u64 pb_last_seen;
+   __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
+   __u16 pb_tag;  /* virtual slot idx for multiple modifying RPCs */
+   __u16 pb_padding0;
+   __u32 pb_padding1;
__u64 pb_last_committed;
__u64 pb_transno;
__u32 pb_flags;
@@ -1125,8 +1127,10 @@ struct ptlrpc_body_v2 {
__u32 pb_version;
__u32 pb_opc;
__u32 pb_status;
-   __u64 pb_last_xid;
-   __u64 pb_last_seen;
+   __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
+   __u16 pb_tag;  /* virtual slot idx for multiple modifying RPCs */
+   __u16 pb_padding0;
+   __u32 pb_padding1;
__u64 pb_last_committed;
__u64 pb_transno;
__u32 pb_flags;
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h 
b/drivers/staging/lustre/lustre/include/lustre_net.h
index e9aba99..ab80330 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -2652,6 +2652,7 @@ struct lustre_handle *lustre_msg_get_handle(struct 
lustre_msg *msg);
 __u32 lustre_msg_get_type(struct lustre_msg *msg);
 void lustre_msg_add_version(struct lustre_msg *msg, u32 version);
 __u32 lustre_msg_get_opc(struct lustre_msg *msg);
+__u16 lustre_msg_get_tag(struct lustre_msg *msg);
 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg);
 __u64 *lustre_msg_get_versions(struct lustre_msg *msg);
 __u64 lustre_msg_get_transno(struct lustre_msg *msg);
@@ -2670,6 +2671,7 @@ void lustre_msg_set_handle(struct lustre_msg *msg,
   struct lustre_handle *handle);
 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc);
+void lustre_msg_set_tag(struct lustre_msg *msg, __u16 tag);
 void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions);
 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno);
 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c 
b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index 2dc0b79..3055649 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -942,6 +942,25 @@ __u32 lustre_msg_get_opc(struct lustre_msg *msg)
 }
 EXPORT_SYMBOL(lustre_msg_get_opc);
 
+__u16 lustre_msg_get_tag(struct lustre_msg *msg)
+{
+   switch (msg->lm_magic) {
+   case LUSTRE_MSG_MAGIC_V2: {
+   struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
+   if (!pb) {
+   CERROR("invalid msg %p: no ptlrpc body!\n", msg);
+   return 0;
+   }
+   return pb->pb_tag;
+   }
+   default:
+   CERROR("incorrect message magic: %08x\n", msg->lm_magic);
+   return 0;
+   }
+}
+EXPORT_SYMBOL(lustre_msg_get_tag);
+
 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
 {
switch (msg->lm_magic) {
@@ -1236,6 +1255,22 @@ void lustre_msg_set_opc(struct lustre_msg *msg, __u32 
opc)
}
 }
 
+void lustre_msg_set_tag(struct lustre_msg *msg, __u16 tag)
+{
+   switch (msg->lm_magic) {
+   case LUSTRE_MSG_MAGIC_V2: {
+   struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
+   

[PATCH 13/41] staging: lustre: clio: use CIT_SETATTR for FSFILT_IOC_SETFLAGS

2016-10-02 Thread James Simmons
From: John L. Hammond 

Add handling of inode flags to the handlers of CIT_SETATTR in lov and
osc. In the FSFILT_IOC_SETFLAGS case of ll_iocontrol() use
cl_setattr_ost() rather than obd_setattr_rqset() to set inode flags on
OST objects. Remove the then unused OBD API methods
obd_setattr_rqset() and obd_setattr_async() along with their
supporting functions.

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5823
Reviewed-on: http://review.whamcloud.com/13422
Reviewed-by: Bobi Jam 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/cl_object.h  |3 +-
 .../staging/lustre/lustre/include/lustre_compat.h  |2 +
 drivers/staging/lustre/lustre/include/obd.h|3 -
 drivers/staging/lustre/lustre/include/obd_class.h  |   39 --
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |8 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |3 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|   33 ++
 drivers/staging/lustre/lustre/llite/vvp_io.c   |   15 ++-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |6 -
 drivers/staging/lustre/lustre/lov/lov_io.c |2 +
 drivers/staging/lustre/lustre/lov/lov_obd.c|   82 
 drivers/staging/lustre/lustre/lov/lov_request.c|  131 
 drivers/staging/lustre/lustre/osc/osc_internal.h   |7 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |   29 +++--
 drivers/staging/lustre/lustre/osc/osc_request.c|   19 +---
 15 files changed, 60 insertions(+), 322 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index 3af9aa3..0b66d02 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1772,9 +1772,10 @@ struct cl_io {
struct cl_io_rw_common ci_rw;
struct cl_setattr_io {
struct ost_lvb   sa_attr;
+   unsigned int sa_attr_flags;
unsigned int sa_valid;
int sa_stripe_index;
-   struct lu_fid  *sa_parent_fid;
+   const struct lu_fid *sa_parent_fid;
} ci_setattr;
struct cl_fault_io {
/** page index within file. */
diff --git a/drivers/staging/lustre/lustre/include/lustre_compat.h 
b/drivers/staging/lustre/lustre/include/lustre_compat.h
index 567c438..300e96f 100644
--- a/drivers/staging/lustre/lustre/include/lustre_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_compat.h
@@ -74,4 +74,6 @@
 # define ext2_find_next_zero_bit  find_next_zero_bit_le
 #endif
 
+#define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
+
 #endif /* _LUSTRE_COMPAT_H */
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 51d5487..fe05cc6 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -896,9 +896,6 @@ struct obd_ops {
   struct obdo *oa, struct obd_trans_info *oti);
int (*setattr)(const struct lu_env *, struct obd_export *exp,
   struct obd_info *oinfo, struct obd_trans_info *oti);
-   int (*setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
-struct obd_trans_info *oti,
-struct ptlrpc_request_set *rqset);
int (*getattr)(const struct lu_env *env, struct obd_export *exp,
   struct obd_info *oinfo);
int (*getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index 2ea102d..b2ced8b 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -749,45 +749,6 @@ static inline int obd_setattr(const struct lu_env *env, 
struct obd_export *exp,
return rc;
 }
 
-/* This performs all the requests set init/wait/destroy actions. */
-static inline int obd_setattr_rqset(struct obd_export *exp,
-   struct obd_info *oinfo,
-   struct obd_trans_info *oti)
-{
-   struct ptlrpc_request_set *set = NULL;
-   int rc;
-
-   EXP_CHECK_DT_OP(exp, setattr_async);
-   EXP_COUNTER_INCREMENT(exp, setattr_async);
-
-   set =  ptlrpc_prep_set();
-   if (!set)
-   return -ENOMEM;
-
-   rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set);
-   if (rc == 0)
-   rc = ptlrpc_set_wait(set);
-   

[PATCH 15/41] staging: lustre: osc: fix bug when setting max_pages_per_rpc

2016-10-02 Thread James Simmons
From: Wu Libin 

After setting like "lctl set_param -P osc.*.max_pages_per_rpc", it
is possible that the function osc_obd_max_pages_per_rpc_seq_write
will be called before ocd_brw_size has been set when mount.
ocd_brw_size is meaningless when it is zero. So it should not be
the limit at that time.

Signed-off-by: Wu Libin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6421
Reviewed-on: http://review.whamcloud.com/14333
Reviewed-by: Emoly Liu 
Reviewed-by: Bobi Jam 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/osc/lproc_osc.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c 
b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index f0062d4..a837362 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -585,7 +585,8 @@ static ssize_t max_pages_per_rpc_store(struct kobject *kobj,
chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_SHIFT)) - 1);
/* max_pages_per_rpc must be chunk aligned */
val = (val + ~chunk_mask) & chunk_mask;
-   if (val == 0 || val > ocd->ocd_brw_size >> PAGE_SHIFT) {
+   if (!val || (ocd->ocd_brw_size &&
+val > ocd->ocd_brw_size >> PAGE_SHIFT)) {
return -ERANGE;
}
spin_lock(>cl_loi_list_lock);
-- 
1.7.1



[PATCH 17/41] staging: lustre: ptlrpc: remove old protocol compatibility

2016-10-02 Thread James Simmons
From: Andreas Dilger 

Some old protocol compatibility workarounds are still present in
master that should have been removed when LUSTRE_MSG_MAGIC_V1 was.

In particular, the process for upgrading LUSTRE_MSG_MAGIC_V1 to
LUSTRE_MSG_MAGIC_V2 had the client to connect to the server with the
V1 protocol with op_flag=MSG_CONNECT_NEXT_VER set, and if the server
supported the V2 protocol it would reply with LUSTRE_MSG_MAGIC_V2.
This ensured that if the new client connected to an old server the
connection would be allowed.  However, even with V1 protocol support
removed, the 2.x clients are still connecting with NEXT_VER set.
In b1_8 this flag was contingent on LUSTRE_MSG_MAGIC_V1 being used,
which is how it should have been in 2.x as well.

A few other cleanups are be done at the same time:
 - disallow 1.8 clients (or at least those that don't understand
   OBD_CONNECT_FULL20) so we can remove workarounds for 1.8 clients
 - remove support for pre-2.1 DLM flock lock handling
 - don't workaround the lack of MDS_ATTR_xTIME_SET flags in setattr
 - always set MSGHDR_CKSUM_INCOMPAT18 (it can eventually be removed)

Signed-off-by: Andreas Dilger 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6349
Reviewed-on: http://review.whamcloud.com/14006
Reviewed-by: James Simmons 
Reviewed-by: Dmitry Eremin 
Reviewed-by: John L. Hammond 
Reviewed-by: Liang Zhen 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c|   18 ++
 drivers/staging/lustre/lustre/ldlm/ldlm_internal.h |7 ++-
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |   19 +++
 drivers/staging/lustre/lustre/ptlrpc/import.c  |   11 ++-
 4 files changed, 9 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index 861f36f..98838e7 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -612,22 +612,8 @@ granted:
 }
 EXPORT_SYMBOL(ldlm_flock_completion_ast);
 
-void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy,
-  ldlm_policy_data_t *lpolicy)
-{
-   memset(lpolicy, 0, sizeof(*lpolicy));
-   lpolicy->l_flock.start = wpolicy->l_flock.lfw_start;
-   lpolicy->l_flock.end = wpolicy->l_flock.lfw_end;
-   lpolicy->l_flock.pid = wpolicy->l_flock.lfw_pid;
-   /* Compat code, old clients had no idea about owner field and
-* relied solely on pid for ownership. Introduced in LU-104, 2.1,
-* April 2011
-*/
-   lpolicy->l_flock.owner = wpolicy->l_flock.lfw_pid;
-}
-
-void ldlm_flock_policy_wire21_to_local(const ldlm_wire_policy_data_t *wpolicy,
-  ldlm_policy_data_t *lpolicy)
+void ldlm_flock_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
+ldlm_policy_data_t *lpolicy)
 {
memset(lpolicy, 0, sizeof(*lpolicy));
lpolicy->l_flock.start = wpolicy->l_flock.lfw_start;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h 
b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
index 5e82cfc..0099ff3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
@@ -329,10 +329,7 @@ void ldlm_extent_policy_wire_to_local(const 
ldlm_wire_policy_data_t *wpolicy,
  ldlm_policy_data_t *lpolicy);
 void ldlm_extent_policy_local_to_wire(const ldlm_policy_data_t *lpolicy,
  ldlm_wire_policy_data_t *wpolicy);
-void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy,
-  ldlm_policy_data_t *lpolicy);
-void ldlm_flock_policy_wire21_to_local(const ldlm_wire_policy_data_t *wpolicy,
-  ldlm_policy_data_t *lpolicy);
-
+void ldlm_flock_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
+ldlm_policy_data_t *lpolicy);
 void ldlm_flock_policy_local_to_wire(const ldlm_policy_data_t *lpolicy,
 ldlm_wire_policy_data_t *wpolicy);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index cc116ba..22b4a52 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -63,17 +63,10 @@ static char *ldlm_typename[] = {
[LDLM_IBITS]= "IBT",
 };
 
-static ldlm_policy_wire_to_local_t ldlm_policy_wire18_to_local[] = {
+static ldlm_policy_wire_to_local_t ldlm_policy_wire_to_local[] = {
[LDLM_PLAIN - LDLM_MIN_TYPE]= 

[PATCH 08/41] staging: lustre: ptlrpc: ret -ECONNREFUSED if not context found in req

2016-10-02 Thread James Simmons
From: Sebastien Buisson 

Return -ECONNREFUSED instead of -ENOMEM in sptlrpc_req_get_ctx()
if no context is found in req. It is more graceful.

Signed-off-by: Sebastien Buisson 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6356
Reviewed-on: http://review.whamcloud.com/14043
Reviewed-by: Dmitry Eremin 
Reviewed-by: Andrew Perepechko 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/ptlrpc/sec.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 5d3995d..1457a6e 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -379,7 +379,7 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req)
 
if (!req->rq_cli_ctx) {
CERROR("req %p: fail to get context\n", req);
-   return -ENOMEM;
+   return -ECONNREFUSED;
}
 
return 0;
-- 
1.7.1



[PATCH 15/41] staging: lustre: osc: fix bug when setting max_pages_per_rpc

2016-10-02 Thread James Simmons
From: Wu Libin 

After setting like "lctl set_param -P osc.*.max_pages_per_rpc", it
is possible that the function osc_obd_max_pages_per_rpc_seq_write
will be called before ocd_brw_size has been set when mount.
ocd_brw_size is meaningless when it is zero. So it should not be
the limit at that time.

Signed-off-by: Wu Libin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6421
Reviewed-on: http://review.whamcloud.com/14333
Reviewed-by: Emoly Liu 
Reviewed-by: Bobi Jam 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/osc/lproc_osc.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c 
b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index f0062d4..a837362 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -585,7 +585,8 @@ static ssize_t max_pages_per_rpc_store(struct kobject *kobj,
chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_SHIFT)) - 1);
/* max_pages_per_rpc must be chunk aligned */
val = (val + ~chunk_mask) & chunk_mask;
-   if (val == 0 || val > ocd->ocd_brw_size >> PAGE_SHIFT) {
+   if (!val || (ocd->ocd_brw_size &&
+val > ocd->ocd_brw_size >> PAGE_SHIFT)) {
return -ERANGE;
}
spin_lock(>cl_loi_list_lock);
-- 
1.7.1



[PATCH 17/41] staging: lustre: ptlrpc: remove old protocol compatibility

2016-10-02 Thread James Simmons
From: Andreas Dilger 

Some old protocol compatibility workarounds are still present in
master that should have been removed when LUSTRE_MSG_MAGIC_V1 was.

In particular, the process for upgrading LUSTRE_MSG_MAGIC_V1 to
LUSTRE_MSG_MAGIC_V2 had the client to connect to the server with the
V1 protocol with op_flag=MSG_CONNECT_NEXT_VER set, and if the server
supported the V2 protocol it would reply with LUSTRE_MSG_MAGIC_V2.
This ensured that if the new client connected to an old server the
connection would be allowed.  However, even with V1 protocol support
removed, the 2.x clients are still connecting with NEXT_VER set.
In b1_8 this flag was contingent on LUSTRE_MSG_MAGIC_V1 being used,
which is how it should have been in 2.x as well.

A few other cleanups are be done at the same time:
 - disallow 1.8 clients (or at least those that don't understand
   OBD_CONNECT_FULL20) so we can remove workarounds for 1.8 clients
 - remove support for pre-2.1 DLM flock lock handling
 - don't workaround the lack of MDS_ATTR_xTIME_SET flags in setattr
 - always set MSGHDR_CKSUM_INCOMPAT18 (it can eventually be removed)

Signed-off-by: Andreas Dilger 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6349
Reviewed-on: http://review.whamcloud.com/14006
Reviewed-by: James Simmons 
Reviewed-by: Dmitry Eremin 
Reviewed-by: John L. Hammond 
Reviewed-by: Liang Zhen 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c|   18 ++
 drivers/staging/lustre/lustre/ldlm/ldlm_internal.h |7 ++-
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |   19 +++
 drivers/staging/lustre/lustre/ptlrpc/import.c  |   11 ++-
 4 files changed, 9 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index 861f36f..98838e7 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -612,22 +612,8 @@ granted:
 }
 EXPORT_SYMBOL(ldlm_flock_completion_ast);
 
-void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy,
-  ldlm_policy_data_t *lpolicy)
-{
-   memset(lpolicy, 0, sizeof(*lpolicy));
-   lpolicy->l_flock.start = wpolicy->l_flock.lfw_start;
-   lpolicy->l_flock.end = wpolicy->l_flock.lfw_end;
-   lpolicy->l_flock.pid = wpolicy->l_flock.lfw_pid;
-   /* Compat code, old clients had no idea about owner field and
-* relied solely on pid for ownership. Introduced in LU-104, 2.1,
-* April 2011
-*/
-   lpolicy->l_flock.owner = wpolicy->l_flock.lfw_pid;
-}
-
-void ldlm_flock_policy_wire21_to_local(const ldlm_wire_policy_data_t *wpolicy,
-  ldlm_policy_data_t *lpolicy)
+void ldlm_flock_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
+ldlm_policy_data_t *lpolicy)
 {
memset(lpolicy, 0, sizeof(*lpolicy));
lpolicy->l_flock.start = wpolicy->l_flock.lfw_start;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h 
b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
index 5e82cfc..0099ff3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
@@ -329,10 +329,7 @@ void ldlm_extent_policy_wire_to_local(const 
ldlm_wire_policy_data_t *wpolicy,
  ldlm_policy_data_t *lpolicy);
 void ldlm_extent_policy_local_to_wire(const ldlm_policy_data_t *lpolicy,
  ldlm_wire_policy_data_t *wpolicy);
-void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy,
-  ldlm_policy_data_t *lpolicy);
-void ldlm_flock_policy_wire21_to_local(const ldlm_wire_policy_data_t *wpolicy,
-  ldlm_policy_data_t *lpolicy);
-
+void ldlm_flock_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
+ldlm_policy_data_t *lpolicy);
 void ldlm_flock_policy_local_to_wire(const ldlm_policy_data_t *lpolicy,
 ldlm_wire_policy_data_t *wpolicy);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index cc116ba..22b4a52 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -63,17 +63,10 @@ static char *ldlm_typename[] = {
[LDLM_IBITS]= "IBT",
 };
 
-static ldlm_policy_wire_to_local_t ldlm_policy_wire18_to_local[] = {
+static ldlm_policy_wire_to_local_t ldlm_policy_wire_to_local[] = {
[LDLM_PLAIN - LDLM_MIN_TYPE]= ldlm_plain_policy_wire_to_local,
[LDLM_EXTENT - LDLM_MIN_TYPE]   = ldlm_extent_policy_wire_to_local,
-   [LDLM_FLOCK - LDLM_MIN_TYPE]= ldlm_flock_policy_wire18_to_local,
-   

[PATCH 08/41] staging: lustre: ptlrpc: ret -ECONNREFUSED if not context found in req

2016-10-02 Thread James Simmons
From: Sebastien Buisson 

Return -ECONNREFUSED instead of -ENOMEM in sptlrpc_req_get_ctx()
if no context is found in req. It is more graceful.

Signed-off-by: Sebastien Buisson 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6356
Reviewed-on: http://review.whamcloud.com/14043
Reviewed-by: Dmitry Eremin 
Reviewed-by: Andrew Perepechko 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/ptlrpc/sec.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 5d3995d..1457a6e 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -379,7 +379,7 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req)
 
if (!req->rq_cli_ctx) {
CERROR("req %p: fail to get context\n", req);
-   return -ENOMEM;
+   return -ECONNREFUSED;
}
 
return 0;
-- 
1.7.1



[PATCH 06/41] staging: lustre: ldlm: remove unnecessary EXPORT_SYMBOL

2016-10-02 Thread James Simmons
From: frank zago 

A lot of symbols don't need to be exported at all because they are
only used in the module they belong to.

Signed-off-by: frank zago 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5829
Reviewed-on: http://review.whamcloud.com/13324
Reviewed-by: James Simmons 
Reviewed-by: John L. Hammond 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |3 ---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|2 --
 drivers/staging/lustre/lustre/ldlm/ldlm_pool.c |6 --
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |3 ---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |4 
 5 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 3c48b4f..ace8cb2 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -512,7 +512,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, 
struct ldlm_lock *lock,
 
return 0;
 }
-EXPORT_SYMBOL(ldlm_lock_change_resource);
 
 /** \defgroup ldlm_handles LDLM HANDLES
  * Ways to get hold of locks without any addresses.
@@ -595,7 +594,6 @@ void ldlm_lock2desc(struct ldlm_lock *lock, struct 
ldlm_lock_desc *desc)
>l_policy_data,
>l_policy_data);
 }
-EXPORT_SYMBOL(ldlm_lock2desc);
 
 /**
  * Add a lock to list of conflicting locks to send AST to.
@@ -1147,7 +1145,6 @@ void ldlm_lock_fail_match_locked(struct ldlm_lock *lock)
wake_up_all(>l_waitq);
}
 }
-EXPORT_SYMBOL(ldlm_lock_fail_match_locked);
 
 /**
  * Mark lock as "matchable" by OST.
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index fde697e..c32b414 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -858,7 +858,6 @@ int ldlm_get_ref(void)
 
return rc;
 }
-EXPORT_SYMBOL(ldlm_get_ref);
 
 void ldlm_put_ref(void)
 {
@@ -875,7 +874,6 @@ void ldlm_put_ref(void)
}
mutex_unlock(_ref_mutex);
 }
-EXPORT_SYMBOL(ldlm_put_ref);
 
 static ssize_t cancel_unused_locks_before_replay_show(struct kobject *kobj,
  struct attribute *attr,
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index 9a1136e..b29c956 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -684,7 +684,6 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct 
ldlm_namespace *ns,
 
return rc;
 }
-EXPORT_SYMBOL(ldlm_pool_init);
 
 void ldlm_pool_fini(struct ldlm_pool *pl)
 {
@@ -698,7 +697,6 @@ void ldlm_pool_fini(struct ldlm_pool *pl)
 */
POISON(pl, 0x5a, sizeof(*pl));
 }
-EXPORT_SYMBOL(ldlm_pool_fini);
 
 /**
  * Add new taken ldlm lock \a lock into pool \a pl accounting.
@@ -724,7 +722,6 @@ void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock 
*lock)
 * with too long call paths.
 */
 }
-EXPORT_SYMBOL(ldlm_pool_add);
 
 /**
  * Remove ldlm lock \a lock from pool \a pl accounting.
@@ -743,7 +740,6 @@ void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock 
*lock)
 
lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_CANCEL_STAT);
 }
-EXPORT_SYMBOL(ldlm_pool_del);
 
 /**
  * Returns current \a pl SLV.
@@ -1095,7 +1091,6 @@ int ldlm_pools_init(void)
 
return rc;
 }
-EXPORT_SYMBOL(ldlm_pools_init);
 
 void ldlm_pools_fini(void)
 {
@@ -1104,4 +1099,3 @@ void ldlm_pools_fini(void)
 
ldlm_pools_thread_stop();
 }
-EXPORT_SYMBOL(ldlm_pools_fini);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 35ba6f1..98730a3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1022,7 +1022,6 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req)
 
return 0;
 }
-EXPORT_SYMBOL(ldlm_cli_update_pool);
 
 /**
  * Client side lock cancel.
@@ -1125,7 +1124,6 @@ int ldlm_cli_cancel_list_local(struct list_head *cancels, 
int count,
 
return count;
 }
-EXPORT_SYMBOL(ldlm_cli_cancel_list_local);
 
 /**
  * Cancel as many locks as possible w/o sending any RPCs (e.g. to write back
@@ -2048,4 +2046,3 @@ int ldlm_replay_locks(struct obd_import *imp)
 
return rc;
 }
-EXPORT_SYMBOL(ldlm_replay_locks);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index a09c25a..07cb955 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -999,7 +999,6 @@ void ldlm_namespace_get(struct ldlm_namespace *ns)
 {
atomic_inc(>ns_bref);
 }

[PATCH 11/41] staging: lustre: ptlrpc: Add OBD_CONNECT_MULTIMODRPCS flag

2016-10-02 Thread James Simmons
From: Gregoire Pichon 

The new OBD_CONNECT_MULTIMODRPCS connection flag indicates the support
of multiple modify RPCs in parallel. It can be specified by the client
within the connection request and by the server within the connection
reply. The new ocd_maxmodrpcs connection data specifies the maximum modify
RPCs in parallel supported by the server.

To allow the MDS to send the new ocd_maxmodrpcs field, it has been
required to modify RMF_CONNECT_DATA so that its size includes the new
field. This change leads to remove the ocd_connect_data_v1 structure.
Note that the client has been allocating an extra 16*sizeof(__u64) for
the obd_connect_data reply since 2.0 and even in later versions of 1.8)
so there is no problem for the MDS to just send the full reply size.

This patch fixes a bug in __req_capsule_get() since it wasn't checking
RMF_F_NO_SIZE_CHECK when receiving the message. This allows legacy
clients (with version lower that this commit) to send connection
request with ocd_connect_data structure size smaller (actually size is
ocd_connect_data_v1 structure size) than new server ocd_connect_data
structure size.

This patch also fixes a bug in the routine that displays the import's
connect data.

Signed-off-by: Gregoire Pichon 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5319
Reviewed-on: http://review.whamcloud.com/#/c/13960
Reviewed-by: Andreas Dilger 
Reviewed-by: Alex Zhuravlev 
Signed-off-by: James Simmons 
---
 .../lustre/lustre/include/lustre/lustre_idl.h  |   26 ---
 .../lustre/lustre/obdclass/lprocfs_status.c|7 -
 drivers/staging/lustre/lustre/ptlrpc/layout.c  |5 ++-
 .../staging/lustre/lustre/ptlrpc/pack_generic.c|3 ++
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c|   14 +-
 5 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 4210716..b88807f 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -1282,6 +1282,9 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 */
 #define OBD_CONNECT_LFSCK  0x40ULL/* support online LFSCK */
 #define OBD_CONNECT_UNLINK_CLOSE 0x100ULL/* close file in unlink */
+#define OBD_CONNECT_MULTIMODRPCS 0x200ULL /* support multiple 
modify
+  *  RPCs in parallel
+  */
 #define OBD_CONNECT_DIR_STRIPE  0x400ULL/* striped DNE dir */
 
 /* XXX README XXX:
@@ -1313,25 +1316,6 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
  * If we eventually have separate connect data for different types, which we
  * almost certainly will, then perhaps we stick a union in here.
  */
-struct obd_connect_data_v1 {
-   __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
-   __u32 ocd_version;   /* lustre release version number */
-   __u32 ocd_grant; /* initial cache grant amount (bytes) */
-   __u32 ocd_index; /* LOV index to connect to */
-   __u32 ocd_brw_size;  /* Maximum BRW size in bytes, must be 2^n */
-   __u64 ocd_ibits_known;   /* inode bits this client understands */
-   __u8  ocd_blocksize; /* log2 of the backend filesystem blocksize */
-   __u8  ocd_inodespace;/* log2 of the per-inode space consumption */
-   __u16 ocd_grant_extent;  /* per-extent grant overhead, in 1K blocks */
-   __u32 ocd_unused;   /* also fix lustre_swab_connect */
-   __u64 ocd_transno;   /* first transno from client to be replayed */
-   __u32 ocd_group; /* MDS group on OST */
-   __u32 ocd_cksum_types;   /* supported checksum algorithms */
-   __u32 ocd_max_easize;/* How big LOV EA can be on MDS */
-   __u32 ocd_instance;  /* also fix lustre_swab_connect */
-   __u64 ocd_maxbytes;  /* Maximum stripe size in bytes */
-};
-
 struct obd_connect_data {
__u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
__u32 ocd_version;   /* lustre release version number */
@@ -1354,7 +1338,9 @@ struct obd_connect_data {
 * any field after ocd_maxbytes on the receiver without a valid flag
 * may result in out-of-bound memory access and kernel oops.
 */
-   __u64 padding1;   /* added 2.1.0. also fix lustre_swab_connect */
+   __u16 ocd_maxmodrpcs;   /* Maximum modify RPCs in parallel */
+   __u16 padding0; /* added 2.1.0. also fix lustre_swab_connect */
+   __u32 padding1; /* added 2.1.0. also fix lustre_swab_connect */
__u64 padding2;   /* added 2.1.0. also fix lustre_swab_connect */
__u64 padding3;   /* added 2.1.0. also fix lustre_swab_connect */
__u64 padding4;   /* added 2.1.0. 

[PATCH 14/41] staging: lustre: ptlrpc: Add a tag field to ptlrpc messages

2016-10-02 Thread James Simmons
From: Gregoire Pichon 

The new tag field is used as a virtual index for multiple modifying
RPCs management. It is set by the client and allows the target to
release in-memory reply data when the tag is reused by a new RPC.

The tag field replaces the unused last_seen field of ptlrpcd_body
structure.

Additionally, the last_xid field is used to transfer the highest XID
for which a reply has been received and does not have an unreplied
lower-numbered XID.

Signed-off-by: Gregoire Pichon 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5319
Reviewed-on: http://review.whamcloud.com/14095
Reviewed-by: Andreas Dilger 
Reviewed-by: Alex Zhuravlev 
Signed-off-by: James Simmons 
---
 .../lustre/lustre/include/lustre/lustre_idl.h  |   12 --
 drivers/staging/lustre/lustre/include/lustre_net.h |2 +
 .../staging/lustre/lustre/ptlrpc/pack_generic.c|   39 +++-
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c|   32 
 4 files changed, 72 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index b88807f..4f6eeec 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -1099,8 +1099,10 @@ struct ptlrpc_body_v3 {
__u32 pb_version;
__u32 pb_opc;
__u32 pb_status;
-   __u64 pb_last_xid;
-   __u64 pb_last_seen;
+   __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
+   __u16 pb_tag;  /* virtual slot idx for multiple modifying RPCs */
+   __u16 pb_padding0;
+   __u32 pb_padding1;
__u64 pb_last_committed;
__u64 pb_transno;
__u32 pb_flags;
@@ -1125,8 +1127,10 @@ struct ptlrpc_body_v2 {
__u32 pb_version;
__u32 pb_opc;
__u32 pb_status;
-   __u64 pb_last_xid;
-   __u64 pb_last_seen;
+   __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
+   __u16 pb_tag;  /* virtual slot idx for multiple modifying RPCs */
+   __u16 pb_padding0;
+   __u32 pb_padding1;
__u64 pb_last_committed;
__u64 pb_transno;
__u32 pb_flags;
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h 
b/drivers/staging/lustre/lustre/include/lustre_net.h
index e9aba99..ab80330 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -2652,6 +2652,7 @@ struct lustre_handle *lustre_msg_get_handle(struct 
lustre_msg *msg);
 __u32 lustre_msg_get_type(struct lustre_msg *msg);
 void lustre_msg_add_version(struct lustre_msg *msg, u32 version);
 __u32 lustre_msg_get_opc(struct lustre_msg *msg);
+__u16 lustre_msg_get_tag(struct lustre_msg *msg);
 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg);
 __u64 *lustre_msg_get_versions(struct lustre_msg *msg);
 __u64 lustre_msg_get_transno(struct lustre_msg *msg);
@@ -2670,6 +2671,7 @@ void lustre_msg_set_handle(struct lustre_msg *msg,
   struct lustre_handle *handle);
 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc);
+void lustre_msg_set_tag(struct lustre_msg *msg, __u16 tag);
 void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions);
 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno);
 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c 
b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index 2dc0b79..3055649 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -942,6 +942,25 @@ __u32 lustre_msg_get_opc(struct lustre_msg *msg)
 }
 EXPORT_SYMBOL(lustre_msg_get_opc);
 
+__u16 lustre_msg_get_tag(struct lustre_msg *msg)
+{
+   switch (msg->lm_magic) {
+   case LUSTRE_MSG_MAGIC_V2: {
+   struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
+   if (!pb) {
+   CERROR("invalid msg %p: no ptlrpc body!\n", msg);
+   return 0;
+   }
+   return pb->pb_tag;
+   }
+   default:
+   CERROR("incorrect message magic: %08x\n", msg->lm_magic);
+   return 0;
+   }
+}
+EXPORT_SYMBOL(lustre_msg_get_tag);
+
 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
 {
switch (msg->lm_magic) {
@@ -1236,6 +1255,22 @@ void lustre_msg_set_opc(struct lustre_msg *msg, __u32 
opc)
}
 }
 
+void lustre_msg_set_tag(struct lustre_msg *msg, __u16 tag)
+{
+   switch (msg->lm_magic) {
+   case LUSTRE_MSG_MAGIC_V2: {
+   struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
+   LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
+   pb->pb_tag = tag;
+   return;
+   

[PATCH 13/41] staging: lustre: clio: use CIT_SETATTR for FSFILT_IOC_SETFLAGS

2016-10-02 Thread James Simmons
From: John L. Hammond 

Add handling of inode flags to the handlers of CIT_SETATTR in lov and
osc. In the FSFILT_IOC_SETFLAGS case of ll_iocontrol() use
cl_setattr_ost() rather than obd_setattr_rqset() to set inode flags on
OST objects. Remove the then unused OBD API methods
obd_setattr_rqset() and obd_setattr_async() along with their
supporting functions.

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5823
Reviewed-on: http://review.whamcloud.com/13422
Reviewed-by: Bobi Jam 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/cl_object.h  |3 +-
 .../staging/lustre/lustre/include/lustre_compat.h  |2 +
 drivers/staging/lustre/lustre/include/obd.h|3 -
 drivers/staging/lustre/lustre/include/obd_class.h  |   39 --
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |8 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |3 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|   33 ++
 drivers/staging/lustre/lustre/llite/vvp_io.c   |   15 ++-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |6 -
 drivers/staging/lustre/lustre/lov/lov_io.c |2 +
 drivers/staging/lustre/lustre/lov/lov_obd.c|   82 
 drivers/staging/lustre/lustre/lov/lov_request.c|  131 
 drivers/staging/lustre/lustre/osc/osc_internal.h   |7 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |   29 +++--
 drivers/staging/lustre/lustre/osc/osc_request.c|   19 +---
 15 files changed, 60 insertions(+), 322 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index 3af9aa3..0b66d02 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1772,9 +1772,10 @@ struct cl_io {
struct cl_io_rw_common ci_rw;
struct cl_setattr_io {
struct ost_lvb   sa_attr;
+   unsigned int sa_attr_flags;
unsigned int sa_valid;
int sa_stripe_index;
-   struct lu_fid  *sa_parent_fid;
+   const struct lu_fid *sa_parent_fid;
} ci_setattr;
struct cl_fault_io {
/** page index within file. */
diff --git a/drivers/staging/lustre/lustre/include/lustre_compat.h 
b/drivers/staging/lustre/lustre/include/lustre_compat.h
index 567c438..300e96f 100644
--- a/drivers/staging/lustre/lustre/include/lustre_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_compat.h
@@ -74,4 +74,6 @@
 # define ext2_find_next_zero_bit  find_next_zero_bit_le
 #endif
 
+#define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
+
 #endif /* _LUSTRE_COMPAT_H */
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 51d5487..fe05cc6 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -896,9 +896,6 @@ struct obd_ops {
   struct obdo *oa, struct obd_trans_info *oti);
int (*setattr)(const struct lu_env *, struct obd_export *exp,
   struct obd_info *oinfo, struct obd_trans_info *oti);
-   int (*setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
-struct obd_trans_info *oti,
-struct ptlrpc_request_set *rqset);
int (*getattr)(const struct lu_env *env, struct obd_export *exp,
   struct obd_info *oinfo);
int (*getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index 2ea102d..b2ced8b 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -749,45 +749,6 @@ static inline int obd_setattr(const struct lu_env *env, 
struct obd_export *exp,
return rc;
 }
 
-/* This performs all the requests set init/wait/destroy actions. */
-static inline int obd_setattr_rqset(struct obd_export *exp,
-   struct obd_info *oinfo,
-   struct obd_trans_info *oti)
-{
-   struct ptlrpc_request_set *set = NULL;
-   int rc;
-
-   EXP_CHECK_DT_OP(exp, setattr_async);
-   EXP_COUNTER_INCREMENT(exp, setattr_async);
-
-   set =  ptlrpc_prep_set();
-   if (!set)
-   return -ENOMEM;
-
-   rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set);
-   if (rc == 0)
-   rc = ptlrpc_set_wait(set);
-   ptlrpc_set_destroy(set);
-   return rc;
-}
-
-/* This adds all the requests into @set if @set != NULL, otherwise
- * all requests are 

[PATCH 09/41] staging: lustre: llite: default dir stripe index only for mkdir

2016-10-02 Thread James Simmons
From: wang di 

Default dir stripe index should only work during mkdir,
otherwise it will cause other open/create request being
sent to the wrong MDT.

Signed-off-by: wang di 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6373
Reviewed-on: http://review.whamcloud.com/14096
Reviewed-by: Alex Zhuravlev 
Reviewed-by: Fan Yong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/llite/llite_lib.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index e75ab2f..c7aab3f 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -2269,8 +2269,9 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data 
*op_data,
op_data->op_default_stripe_offset = -1;
if (S_ISDIR(i1->i_mode)) {
op_data->op_mea1 = ll_i2info(i1)->lli_lsm_md;
-   op_data->op_default_stripe_offset =
-   ll_i2info(i1)->lli_def_stripe_offset;
+   if (opc == LUSTRE_OPC_MKDIR)
+   op_data->op_default_stripe_offset =
+   ll_i2info(i1)->lli_def_stripe_offset;
}
 
if (i2) {
-- 
1.7.1



[PATCH 24/41] staging: lustre: clio: add CIT_DATA_VERSION and remove IOC_LOV_GETINFO

2016-10-02 Thread James Simmons
From: John L. Hammond 

During development a new api, cl_object_obd_info_get()
and cl_object_data_version() which then were later
replaced by a better solution CIT_DATA_VERSION. For
the case of the upstream client their is no point in
introducing a API to only have it removed later. Due
to the way the patches landed with their dependencies
it is not possible to separate out two patches. These
two combined patches do the following:

 * Add a new cl_io type CIT_DATA_VERSION to get file
   data version.
 * Remove the unused IOC_LOV_GETINFO ioctl.
 * Remove ll_glimpse_ioctl() and ll_lsm_getattr().
 * Remove the OBD API method obd_getattr_async().

Signed-off-by: John L. Hammond 
Signed-off-by: Bobi Jam 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5823
Reviewed-on: http://review.whamcloud.com/12748
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6356
Reviewed-on: http://review.whamcloud.com/14649
Reviewed-by: Henri Doreau 
Reviewed-by: Jinshan Xiong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/cl_object.h  |6 +
 .../lustre/lustre/include/lustre/lustre_user.h |6 +-
 drivers/staging/lustre/lustre/include/obd.h|2 -
 drivers/staging/lustre/lustre/include/obd_class.h  |   13 --
 drivers/staging/lustre/lustre/llite/dir.c  |   71 --
 drivers/staging/lustre/lustre/llite/file.c |  125 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |2 -
 drivers/staging/lustre/lustre/lov/lov_internal.h   |4 -
 drivers/staging/lustre/lustre/lov/lov_io.c |   40 ++
 drivers/staging/lustre/lustre/lov/lov_merge.c  |   50 ---
 drivers/staging/lustre/lustre/lov/lov_obd.c|   69 --
 drivers/staging/lustre/lustre/lov/lov_request.c|  144 
 drivers/staging/lustre/lustre/obdclass/cl_io.c |1 +
 drivers/staging/lustre/lustre/osc/osc_io.c |  105 ++
 drivers/staging/lustre/lustre/osc/osc_request.c|   59 
 15 files changed, 189 insertions(+), 508 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index 0b66d02..e46a510 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1373,6 +1373,8 @@ enum cl_io_type {
CIT_WRITE,
/** truncate, utime system calls */
CIT_SETATTR,
+   /** get data version */
+   CIT_DATA_VERSION,
/**
 * page fault handling
 */
@@ -1777,6 +1779,10 @@ struct cl_io {
int sa_stripe_index;
const struct lu_fid *sa_parent_fid;
} ci_setattr;
+   struct cl_data_version_io {
+   u64 dv_data_version;
+   int dv_flags;
+   } ci_data_version;
struct cl_fault_io {
/** page index within file. */
pgoff_t  ft_index;
diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
index dced31f..043fc1c 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
@@ -63,9 +63,13 @@
 #if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64)
 typedef struct stat64   lstat_t;
 #define lstat_f  lstat64
+#define fstat_ffstat64
+#define fstatat_f  fstatat64
 #else
 typedef struct stat lstat_t;
 #define lstat_f  lstat
+#define fstat_ffstat
+#define fstatat_f  fstatat
 #endif
 
 #define HAVE_LOV_USER_MDS_DATA
@@ -234,7 +238,7 @@ struct ost_id {
 /* #define LL_IOC_POLL_QUOTACHECK  161 OBD_IOC_POLL_QUOTACHECK */
 /* #define LL_IOC_QUOTACTL 162 OBD_IOC_QUOTACTL */
 #define IOC_OBD_STATFS   _IOWR('f', 164, struct obd_statfs *)
-#define IOC_LOV_GETINFO _IOWR('f', 165, struct 
lov_user_mds_data *)
+/* IOC_LOV_GETINFO 165 obsolete */
 #define LL_IOC_FLUSHCTX _IOW('f', 166, long)
 /* LL_IOC_RMTACL   167 obsolete */
 #define LL_IOC_GETOBDCOUNT   _IOR('f', 168, long)
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index c72a1e1..f254d88 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -905,8 +905,6 @@ struct obd_ops {
   struct obd_info *oinfo, struct obd_trans_info *oti);
int (*getattr)(const struct lu_env *env, struct obd_export *exp,
   struct obd_info *oinfo);
-   int (*getattr_async)(struct obd_export *exp, 

[PATCH 09/41] staging: lustre: llite: default dir stripe index only for mkdir

2016-10-02 Thread James Simmons
From: wang di 

Default dir stripe index should only work during mkdir,
otherwise it will cause other open/create request being
sent to the wrong MDT.

Signed-off-by: wang di 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6373
Reviewed-on: http://review.whamcloud.com/14096
Reviewed-by: Alex Zhuravlev 
Reviewed-by: Fan Yong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/llite/llite_lib.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index e75ab2f..c7aab3f 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -2269,8 +2269,9 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data 
*op_data,
op_data->op_default_stripe_offset = -1;
if (S_ISDIR(i1->i_mode)) {
op_data->op_mea1 = ll_i2info(i1)->lli_lsm_md;
-   op_data->op_default_stripe_offset =
-   ll_i2info(i1)->lli_def_stripe_offset;
+   if (opc == LUSTRE_OPC_MKDIR)
+   op_data->op_default_stripe_offset =
+   ll_i2info(i1)->lli_def_stripe_offset;
}
 
if (i2) {
-- 
1.7.1



[PATCH 24/41] staging: lustre: clio: add CIT_DATA_VERSION and remove IOC_LOV_GETINFO

2016-10-02 Thread James Simmons
From: John L. Hammond 

During development a new api, cl_object_obd_info_get()
and cl_object_data_version() which then were later
replaced by a better solution CIT_DATA_VERSION. For
the case of the upstream client their is no point in
introducing a API to only have it removed later. Due
to the way the patches landed with their dependencies
it is not possible to separate out two patches. These
two combined patches do the following:

 * Add a new cl_io type CIT_DATA_VERSION to get file
   data version.
 * Remove the unused IOC_LOV_GETINFO ioctl.
 * Remove ll_glimpse_ioctl() and ll_lsm_getattr().
 * Remove the OBD API method obd_getattr_async().

Signed-off-by: John L. Hammond 
Signed-off-by: Bobi Jam 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5823
Reviewed-on: http://review.whamcloud.com/12748
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6356
Reviewed-on: http://review.whamcloud.com/14649
Reviewed-by: Henri Doreau 
Reviewed-by: Jinshan Xiong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/cl_object.h  |6 +
 .../lustre/lustre/include/lustre/lustre_user.h |6 +-
 drivers/staging/lustre/lustre/include/obd.h|2 -
 drivers/staging/lustre/lustre/include/obd_class.h  |   13 --
 drivers/staging/lustre/lustre/llite/dir.c  |   71 --
 drivers/staging/lustre/lustre/llite/file.c |  125 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |2 -
 drivers/staging/lustre/lustre/lov/lov_internal.h   |4 -
 drivers/staging/lustre/lustre/lov/lov_io.c |   40 ++
 drivers/staging/lustre/lustre/lov/lov_merge.c  |   50 ---
 drivers/staging/lustre/lustre/lov/lov_obd.c|   69 --
 drivers/staging/lustre/lustre/lov/lov_request.c|  144 
 drivers/staging/lustre/lustre/obdclass/cl_io.c |1 +
 drivers/staging/lustre/lustre/osc/osc_io.c |  105 ++
 drivers/staging/lustre/lustre/osc/osc_request.c|   59 
 15 files changed, 189 insertions(+), 508 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index 0b66d02..e46a510 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1373,6 +1373,8 @@ enum cl_io_type {
CIT_WRITE,
/** truncate, utime system calls */
CIT_SETATTR,
+   /** get data version */
+   CIT_DATA_VERSION,
/**
 * page fault handling
 */
@@ -1777,6 +1779,10 @@ struct cl_io {
int sa_stripe_index;
const struct lu_fid *sa_parent_fid;
} ci_setattr;
+   struct cl_data_version_io {
+   u64 dv_data_version;
+   int dv_flags;
+   } ci_data_version;
struct cl_fault_io {
/** page index within file. */
pgoff_t  ft_index;
diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
index dced31f..043fc1c 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
@@ -63,9 +63,13 @@
 #if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64)
 typedef struct stat64   lstat_t;
 #define lstat_f  lstat64
+#define fstat_ffstat64
+#define fstatat_f  fstatat64
 #else
 typedef struct stat lstat_t;
 #define lstat_f  lstat
+#define fstat_ffstat
+#define fstatat_f  fstatat
 #endif
 
 #define HAVE_LOV_USER_MDS_DATA
@@ -234,7 +238,7 @@ struct ost_id {
 /* #define LL_IOC_POLL_QUOTACHECK  161 OBD_IOC_POLL_QUOTACHECK */
 /* #define LL_IOC_QUOTACTL 162 OBD_IOC_QUOTACTL */
 #define IOC_OBD_STATFS   _IOWR('f', 164, struct obd_statfs *)
-#define IOC_LOV_GETINFO _IOWR('f', 165, struct 
lov_user_mds_data *)
+/* IOC_LOV_GETINFO 165 obsolete */
 #define LL_IOC_FLUSHCTX _IOW('f', 166, long)
 /* LL_IOC_RMTACL   167 obsolete */
 #define LL_IOC_GETOBDCOUNT   _IOR('f', 168, long)
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index c72a1e1..f254d88 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -905,8 +905,6 @@ struct obd_ops {
   struct obd_info *oinfo, struct obd_trans_info *oti);
int (*getattr)(const struct lu_env *env, struct obd_export *exp,
   struct obd_info *oinfo);
-   int (*getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
-struct ptlrpc_request_set *set);
int (*preprw)(const struct lu_env *env, int cmd,
 

[PATCH 21/41] staging: lustre: mdc: Removed unneeded NULL check

2016-10-02 Thread James Simmons
From: Henri Doreau 

Do not bother checking the return value of changelog_kuc_hdr()
against NULL since this value was dereferenced earlier.

Signed-off-by: Henri Doreau 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4189
Reviewed-on: http://review.whamcloud.com/12919
Reviewed-by: John L. Hammond 
Reviewed-by: Faccini Bruno 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/mdc/mdc_request.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index d996326..206f5d0 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1867,10 +1867,8 @@ static int mdc_changelog_send_thread(void *csdata)
 
/* Send EOF no matter what our result */
kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch), cs->cs_flags);
-   if (kuch) {
-   kuch->kuc_msgtype = CL_EOF;
-   libcfs_kkuc_msg_put(cs->cs_fp, kuch);
-   }
+   kuch->kuc_msgtype = CL_EOF;
+   libcfs_kkuc_msg_put(cs->cs_fp, kuch);
 
 out:
fput(cs->cs_fp);
-- 
1.7.1



[PATCH 37/41] staging: lustre: lov: copy_to_user uses wrong casting

2016-10-02 Thread James Simmons
With certain version of gcc lov_obd.c failes to compile
with the following warning.

In function copy_to_user,
inlined from lov_iocontrol at
lustre/lustre/lov/lov_obd.c:1168:
./arch/x86/include/asm/uaccess.h:735: error: call to
__copy_to_user_overflow declared with attribute warning:
copy_to_user() buffer size is not probably correct

In lov_iocontrol the data was being casted to int instead
of the required unsigned long. This patch changes the cast
to what is needed for copy_to_user.

Signed-off-by: James Simmons 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6302
Reviewed-on: http://review.whamcloud.com/14613
Reviewed-by: frank zago 
Reviewed-by: Dmitry Eremin 
Reviewed-by: John L. Hammond 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/lov/lov_obd.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c 
b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 473071c..18cb92d 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1085,8 +1085,8 @@ static int lov_iocontrol(unsigned int cmd, struct 
obd_export *exp, int len,
 
/* copy UUID */
if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd),
-min((int)data->ioc_plen2,
-(int)sizeof(struct obd_uuid
+min_t(unsigned long, data->ioc_plen2,
+  sizeof(struct obd_uuid
return -EFAULT;
 
memcpy(, data->ioc_inlbuf1, sizeof(__u32));
@@ -1099,8 +1099,8 @@ static int lov_iocontrol(unsigned int cmd, struct 
obd_export *exp, int len,
if (rc)
return rc;
if (copy_to_user(data->ioc_pbuf1, _buf,
-min((int)data->ioc_plen1,
-(int)sizeof(stat_buf
+min_t(unsigned long, data->ioc_plen1,
+  sizeof(stat_buf
return -EFAULT;
break;
}
-- 
1.7.1



[PATCH 29/41] staging: lustre: ptlrpc: Move NRS structures out of lustre_net.h

2016-10-02 Thread James Simmons
From: Chris Horn 

NRS specific structures are not needed in the rest of the PtlRPC code.
It is more appropriate for these structures to be defined in a
separate header. This commit creates a lustre_nrs.h header for the
generic NRS structures, and policy-specific headers for the various
NRS policies.

Signed-off-by: Chris Horn 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2667
Reviewed-on: http://review.whamcloud.com/13966
Reviewed-by: Henri Doreau 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/lustre_net.h |  712 +---
 drivers/staging/lustre/lustre/include/lustre_nrs.h |  717 
 .../lustre/lustre/include/lustre_nrs_fifo.h|   70 ++
 3 files changed, 788 insertions(+), 711 deletions(-)
 create mode 100644 drivers/staging/lustre/lustre/include/lustre_nrs.h
 create mode 100644 drivers/staging/lustre/lustre/include/lustre_nrs_fifo.h

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h 
b/drivers/staging/lustre/lustre/include/lustre_net.h
index ab80330..7302238 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -515,717 +515,7 @@ struct lu_env;
 
 struct ldlm_lock;
 
-/**
- * \defgroup nrs Network Request Scheduler
- * @{
- */
-struct ptlrpc_nrs_policy;
-struct ptlrpc_nrs_resource;
-struct ptlrpc_nrs_request;
-
-/**
- * NRS control operations.
- *
- * These are common for all policies.
- */
-enum ptlrpc_nrs_ctl {
-   /**
-* Not a valid opcode.
-*/
-   PTLRPC_NRS_CTL_INVALID,
-   /**
-* Activate the policy.
-*/
-   PTLRPC_NRS_CTL_START,
-   /**
-* Reserved for multiple primary policies, which may be a possibility
-* in the future.
-*/
-   PTLRPC_NRS_CTL_STOP,
-   /**
-* Policies can start using opcodes from this value and onwards for
-* their own purposes; the assigned value itself is arbitrary.
-*/
-   PTLRPC_NRS_CTL_1ST_POL_SPEC = 0x20,
-};
-
-/**
- * ORR policy operations
- */
-enum nrs_ctl_orr {
-   NRS_CTL_ORR_RD_QUANTUM = PTLRPC_NRS_CTL_1ST_POL_SPEC,
-   NRS_CTL_ORR_WR_QUANTUM,
-   NRS_CTL_ORR_RD_OFF_TYPE,
-   NRS_CTL_ORR_WR_OFF_TYPE,
-   NRS_CTL_ORR_RD_SUPP_REQ,
-   NRS_CTL_ORR_WR_SUPP_REQ,
-};
-
-/**
- * NRS policy operations.
- *
- * These determine the behaviour of a policy, and are called in response to
- * NRS core events.
- */
-struct ptlrpc_nrs_pol_ops {
-   /**
-* Called during policy registration; this operation is optional.
-*
-* \param[in,out] policy The policy being initialized
-*/
-   int (*op_policy_init)(struct ptlrpc_nrs_policy *policy);
-   /**
-* Called during policy unregistration; this operation is optional.
-*
-* \param[in,out] policy The policy being unregistered/finalized
-*/
-   void(*op_policy_fini)(struct ptlrpc_nrs_policy *policy);
-   /**
-* Called when activating a policy via lprocfs; policies allocate and
-* initialize their resources here; this operation is optional.
-*
-* \param[in,out] policy The policy being started
-*
-* \see nrs_policy_start_locked()
-*/
-   int (*op_policy_start)(struct ptlrpc_nrs_policy *policy);
-   /**
-* Called when deactivating a policy via lprocfs; policies deallocate
-* their resources here; this operation is optional
-*
-* \param[in,out] policy The policy being stopped
-*
-* \see nrs_policy_stop0()
-*/
-   void(*op_policy_stop)(struct ptlrpc_nrs_policy *policy);
-   /**
-* Used for policy-specific operations; i.e. not generic ones like
-* \e PTLRPC_NRS_CTL_START and \e PTLRPC_NRS_CTL_GET_INFO; analogous
-* to an ioctl; this operation is optional.
-*
-* \param[in,out]policy The policy carrying out operation \a opc
-* \param[in] opcThe command operation being carried out
-* \param[in,out] argAn generic buffer for communication between the
-*   user and the control operation
-*
-* \retval -ve error
-* \retval   0 success
-*
-* \see ptlrpc_nrs_policy_control()
-*/
-   int (*op_policy_ctl)(struct ptlrpc_nrs_policy *policy,
-enum ptlrpc_nrs_ctl opc, void *arg);
-
-   /**
-* Called when obtaining references to the resources of the resource
-* hierarchy for a request that has arrived for handling at the PTLRPC
-* service. Policies should return -ve for requests they do not wish
-* to handle. This operation is mandatory.
-*
-* 

[PATCH 35/41] staging: lustre: hsm: Use file lease to implement migration

2016-10-02 Thread James Simmons
From: Henri Doreau 

Implement non-blocking migration based on exclusive open instead of
group lock. Implemented exclusive close operation to atomically put
a lease, swap two layouts and close a file. This allows race-free
migrations.

Make the caller responsible for retrying on failure (EBUSY, EAGAIN)
in non-blocking mode.

In blocking mode, allow applications to trigger layout swaps using a
grouplock they already own, to prevent race conditions between the
actual data copy and the layout swap. Updated lfs accordingly. File
leases are also taken in blocking mode, so that lfs migrate can issue
a warning if an application attempts to open a file that is being
migrated and gets blocked.

Timestamps (atime/mtime) are set from userland, after the layout swap
is performed, to prevent conflicts with the grouplock.

lli_trunc_sem is taken/released in the vvp_io layer, under the DLM
lock. This re-ordering fixes the original issue between truncate and
migrate.

Signed-off-by: Henri Doreau 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4840
Reviewed-on: http://review.whamcloud.com/10013
Reviewed-by: John L. Hammond 
Reviewed-by: frank zago 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 .../lustre/lustre/include/lustre/lustre_idl.h  |5 +-
 .../lustre/lustre/include/lustre/lustre_user.h |1 +
 .../lustre/lustre/include/lustre_req_layout.h  |2 +-
 drivers/staging/lustre/lustre/llite/file.c |  231 
 drivers/staging/lustre/lustre/llite/llite_lib.c|4 -
 drivers/staging/lustre/lustre/llite/vvp_io.c   |   82 +---
 drivers/staging/lustre/lustre/mdc/mdc_lib.c|   34 ++--
 drivers/staging/lustre/lustre/mdc/mdc_request.c|7 +-
 drivers/staging/lustre/lustre/ptlrpc/layout.c  |   10 +-
 9 files changed, 235 insertions(+), 141 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 5d2f845..7de8098 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -1703,7 +1703,9 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 
lmm_magic)
 /* OBD_MD_FLRMTRGETFACL (0x0008ULL) lfs rgetfacl, obsolete */
 
 #define OBD_MD_FLDATAVERSION (0x0010ULL) /* iversion sum */
-#define OBD_MD_FLRELEASED(0x0020ULL) /* file released */
+#define OBD_MD_CLOSE_INTENT_EXECED (0x0020ULL) /* close intent
+   * executed
+   */
 
 #define OBD_MD_DEFAULT_MEA   (0x0040ULL) /* default MEA */
 
@@ -2235,6 +2237,7 @@ enum mds_op_bias {
MDS_OWNEROVERRIDE   = 1 << 11,
MDS_HSM_RELEASE = 1 << 12,
MDS_RENAME_MIGRATE  = BIT(13),
+   MDS_CLOSE_LAYOUT_SWAP   = BIT(14),
 };
 
 /* instance of mdt_reint_rec */
diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
index 856e2f9..579ef14 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
@@ -650,6 +650,7 @@ struct if_quotactl {
 #define SWAP_LAYOUTS_CHECK_DV2 (1 << 1)
 #define SWAP_LAYOUTS_KEEP_MTIME(1 << 2)
 #define SWAP_LAYOUTS_KEEP_ATIME(1 << 3)
+#define SWAP_LAYOUTS_CLOSE BIT(4)
 
 /* Swap XATTR_NAME_HSM as well, only on the MDT so far */
 #define SWAP_LAYOUTS_MDS_HSM   (1 << 31)
diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h 
b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
index 78857b3..7657132 100644
--- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h
+++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
@@ -148,7 +148,7 @@ extern struct req_format RQF_MDS_GETATTR;
  */
 extern struct req_format RQF_MDS_GETATTR_NAME;
 extern struct req_format RQF_MDS_CLOSE;
-extern struct req_format RQF_MDS_RELEASE_CLOSE;
+extern struct req_format RQF_MDS_INTENT_CLOSE;
 extern struct req_format RQF_MDS_CONNECT;
 extern struct req_format RQF_MDS_DISCONNECT;
 extern struct req_format RQF_MDS_GET_INFO;
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 9bf50bf..b9cadd9 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -113,10 +113,19 @@ out:
   0, 0, LUSTRE_OPC_ANY, NULL);
 }
 
+/**
+ * Perform a close, possibly with a bias.
+ * The meaning of "data" depends on the value of "bias".
+ *
+ * If \a bias is MDS_HSM_RELEASE then \a data is a pointer 

[PATCH 38/41] staging: lustre: mdc: add max modify RPCs in flight variable

2016-10-02 Thread James Simmons
From: Gregoire Pichon 

This patch introduces the maximum modify RPCs in flight variable of
a mdc client obd device. Its value is set from connection flag and
and connection data. It can later be tuned through the
max_mod_rpcs_in_flight procfs file.

Signed-off-by: Gregoire Pichon 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5319
Reviewed-on: http://review.whamcloud.com/14153
Reviewed-by: Andreas Dilger 
Reviewed-by: Dmitry Eremin 
Reviewed-by: Mike Pershin 
Reviewed-by: Alex Zhuravlev 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h   |7 +++
 drivers/staging/lustre/lustre/include/obd_class.h |1 +
 drivers/staging/lustre/lustre/mdc/lproc_mdc.c |   38 ++
 drivers/staging/lustre/lustre/mdc/mdc_request.c   |4 ++
 drivers/staging/lustre/lustre/obdclass/genops.c   |   57 +
 drivers/staging/lustre/lustre/ptlrpc/import.c |   11 
 6 files changed, 118 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 5fa5838..a977388 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -318,6 +318,13 @@ struct client_obd {
struct mdc_rpc_lock *cl_rpc_lock;
struct mdc_rpc_lock *cl_close_lock;
 
+   /* modify rpcs in flight
+* currently used for metadata only
+*/
+   spinlock_t   cl_mod_rpcs_lock;
+   u16  cl_max_mod_rpcs_in_flight;
+
+
/* mgc datastruct */
atomic_t cl_mgc_refcount;
struct obd_export   *cl_mgc_mgsexp;
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index e6ae4a0..7d8f062 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -100,6 +100,7 @@ int obd_get_request_slot(struct client_obd *cli);
 void obd_put_request_slot(struct client_obd *cli);
 __u32 obd_get_max_rpcs_in_flight(struct client_obd *cli);
 int obd_set_max_rpcs_in_flight(struct client_obd *cli, __u32 max);
+int obd_set_max_mod_rpcs_in_flight(struct client_obd *cli, u16 max);
 
 struct llog_handle;
 struct llog_rec_hdr;
diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c 
b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
index fca9450..5fdee9e 100644
--- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
+++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
@@ -73,6 +73,43 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
 }
 LUSTRE_RW_ATTR(max_rpcs_in_flight);
 
+static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj,
+  struct attribute *attr,
+  char *buf)
+{
+   struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+   u16 max;
+   int len;
+
+   max = dev->u.cli.cl_max_mod_rpcs_in_flight;
+   len = sprintf(buf, "%hu\n", max);
+
+   return len;
+}
+
+static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj,
+   struct attribute *attr,
+   const char *buffer,
+   size_t count)
+{
+   struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+   u16 val;
+   int rc;
+
+   rc = kstrtou16(buffer, 10, );
+   if (rc)
+   return rc;
+
+   rc = obd_set_max_mod_rpcs_in_flight(>u.cli, val);
+   if (rc)
+   count = rc;
+
+   return count;
+}
+LUSTRE_RW_ATTR(max_mod_rpcs_in_flight);
+
 LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
 
 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
@@ -117,6 +154,7 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
 
 static struct attribute *mdc_attrs[] = {
_attr_max_rpcs_in_flight.attr,
+   _attr_max_mod_rpcs_in_flight.attr,
_attr_max_pages_per_rpc.attr,
NULL,
 };
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index ac04bf3..af373af 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -2634,8 +2634,12 @@ static int mdc_setup(struct obd_device *obd, struct 
lustre_cfg *cfg)
if (rc) {
mdc_cleanup(obd);
CERROR("failed to setup llogging subsystems\n");
+   return rc;
}
 
+   spin_lock_init(>cl_mod_rpcs_lock);
+   cli->cl_max_mod_rpcs_in_flight = OBD_MAX_RIF_DEFAULT - 1;

[PATCH 33/41] staging: lustre: lov: use obd_get_info() to get def/max LOV EA sizes

2016-10-02 Thread James Simmons
From: John L. Hammond 

Use obd_get_info() to get the default and maximum LOV EA sizes (along
with maximum cookiesize) from LOV. Remove the then unused function
obd_size_diskmd() and the unused get info key KEY_LOVDESC. When
computing the maximum LOV EA size use the active OST count
(ld_active_tgt_count) rather than the OST count (ld_tgt_count).

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13695
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|1 -
 drivers/staging/lustre/lustre/include/obd_class.h  |6 ---
 drivers/staging/lustre/lustre/llite/lcommon_misc.c |   34 ++--
 drivers/staging/lustre/lustre/llite/llite_lib.c|   10 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c|   24 +++--
 5 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 4691121..5fa5838 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -667,7 +667,6 @@ enum obd_cleanup_stage {
 #define KEY_INTERMDS   "inter_mds"
 #define KEY_LAST_ID "last_id"
 #define KEY_LAST_FID   "last_fid"
-#define KEY_LOVDESC "lovdesc"
 #define KEY_MAX_EASIZE "max_easize"
 #define KEY_DEFAULT_EASIZE "default_easize"
 #define KEY_MGSSEC   "mgssec"
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index a27dbc8..e6ae4a0 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -628,12 +628,6 @@ static inline int obd_packmd(struct obd_export *exp,
return rc;
 }
 
-static inline int obd_size_diskmd(struct obd_export *exp,
- struct lov_stripe_md *mem_src)
-{
-   return obd_packmd(exp, NULL, mem_src);
-}
-
 static inline int obd_free_diskmd(struct obd_export *exp,
  struct lov_mds_md **disk_tgt)
 {
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c 
b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
index 4562643..1558b55 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
@@ -47,29 +47,29 @@
  */
 int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
 {
-   struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC_V3 };
-   __u32 valsize = sizeof(struct lov_desc);
-   int rc, easize, def_easize;
-   struct lov_desc desc;
-   __u16 stripes, def_stripes;
-
-   rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC,
- , );
+   u32 val_size, max_easize, def_easize;
+   int rc;
+
+   val_size = sizeof(max_easize);
+   rc = obd_get_info(NULL, dt_exp, sizeof(KEY_MAX_EASIZE), KEY_MAX_EASIZE,
+ _size, _easize);
if (rc)
return rc;
 
-   stripes = min_t(__u32, desc.ld_tgt_count, LOV_MAX_STRIPE_COUNT);
-   lsm.lsm_stripe_count = stripes;
-   easize = obd_size_diskmd(dt_exp, );
-
-   def_stripes = min_t(__u32, desc.ld_default_stripe_count,
-   LOV_MAX_STRIPE_COUNT);
-   lsm.lsm_stripe_count = def_stripes;
-   def_easize = obd_size_diskmd(dt_exp, );
+   val_size = sizeof(def_easize);
+   rc = obd_get_info(NULL, dt_exp, sizeof(KEY_DEFAULT_EASIZE),
+ KEY_DEFAULT_EASIZE, _size, _easize);
+   if (rc)
+   return rc;
 
-   CDEBUG(D_HA, "updating def/max_easize: %d/%d\n", def_easize, easize);
+   /*
+* default cookiesize is 0 because from 2.4 server doesn't send
+* llog cookies to client.
+*/
+   CDEBUG(D_HA, "updating def/max_easize: %d/%d\n",
+  def_easize, max_easize);
 
-   rc = md_init_ea_size(md_exp, easize, def_easize);
+   rc = md_init_ea_size(md_exp, max_easize, def_easize);
return rc;
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 25a06f8..84d5556 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -560,7 +560,15 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize)
 {
int size, rc;
 
-   *lmmsize = obd_size_diskmd(sbi->ll_dt_exp, NULL);
+   size = sizeof(*lmmsize);
+   rc = obd_get_info(NULL, sbi->ll_dt_exp, sizeof(KEY_MAX_EASIZE),
+ KEY_MAX_EASIZE, , lmmsize);
+   if (rc) {
+   CERROR("%s: cannot get 

[PATCH 39/41] staging: lustre: osc: remove remaining bits for capa support

2016-10-02 Thread James Simmons
From: John L. Hammond 

With capa support removed from the OSC layer a few more bits
can be cleaned up. Convert the OBD getattr and setattr paths
to use struct obdo rather than struct obd_info. Remove
the oi_policy, oi_oa, and oi_capa members from struct obd_info.

Signed-off-by: John L. Hammond 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3105
Reviewed-on: http://review.whamcloud.com/14640
Reviewed-by: Andreas Dilger 
Reviewed-by: Alex Zhuravlev 
Reviewed-by: James Simmons 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|   13 +
 drivers/staging/lustre/lustre/include/obd_class.h  |   17 
 drivers/staging/lustre/lustre/llite/vvp_internal.h |1 -
 drivers/staging/lustre/lustre/lov/lov_obd.c|7 ++-
 drivers/staging/lustre/lustre/lov/lov_request.c|2 -
 .../staging/lustre/lustre/obdecho/echo_client.c|   12 +
 .../staging/lustre/lustre/osc/osc_cl_internal.h|1 -
 drivers/staging/lustre/lustre/osc/osc_internal.h   |6 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |   11 +
 drivers/staging/lustre/lustre/osc/osc_request.c|   45 ++--
 10 files changed, 46 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index a977388..f63336f 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -126,17 +126,10 @@ typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
 
 /* obd info for a particular level (lov, osc). */
 struct obd_info {
-   /* Flags used for set request specific flags:
-  - while lock handling, the flags obtained on the enqueue
-  request are set here.
-  - while stats, the flags used for control delay/resend.
-  - while setattr, the flags used for distinguish punch operation
-*/
+   /* OBD_STATFS_* flags */
__u64  oi_flags;
/* lsm data specific for every OSC. */
struct lov_stripe_md   *oi_md;
-   /* obdo data specific for every OSC, if needed at all. */
-   struct obdo *oi_oa;
/* statfs data specific for every OSC, if needed at all. */
struct obd_statfs  *oi_osfs;
/* An update callback which is called to update some data on upper
@@ -871,9 +864,9 @@ struct obd_ops {
int (*destroy)(const struct lu_env *env, struct obd_export *exp,
   struct obdo *oa);
int (*setattr)(const struct lu_env *, struct obd_export *exp,
-  struct obd_info *oinfo);
+  struct obdo *oa);
int (*getattr)(const struct lu_env *env, struct obd_export *exp,
-  struct obd_info *oinfo);
+  struct obdo *oa);
int (*preprw)(const struct lu_env *env, int cmd,
  struct obd_export *exp, struct obdo *oa, int objcount,
  struct obd_ioobj *obj, struct niobuf_remote *remote,
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index 7d8f062..0eaea54 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -705,26 +705,26 @@ static inline int obd_destroy(const struct lu_env *env, 
struct obd_export *exp,
 }
 
 static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp,
- struct obd_info *oinfo)
+ struct obdo *oa)
 {
int rc;
 
EXP_CHECK_DT_OP(exp, getattr);
EXP_COUNTER_INCREMENT(exp, getattr);
 
-   rc = OBP(exp->exp_obd, getattr)(env, exp, oinfo);
+   rc = OBP(exp->exp_obd, getattr)(env, exp, oa);
return rc;
 }
 
 static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp,
- struct obd_info *oinfo)
+ struct obdo *oa)
 {
int rc;
 
EXP_CHECK_DT_OP(exp, setattr);
EXP_COUNTER_INCREMENT(exp, setattr);
 
-   rc = OBP(exp->exp_obd, setattr)(env, exp, oinfo);
+   rc = OBP(exp->exp_obd, setattr)(env, exp, oa);
return rc;
 }
 
@@ -991,15 +991,16 @@ static inline int obd_statfs_rqset(struct obd_export *exp,
   __u32 flags)
 {
struct ptlrpc_request_set *set = NULL;
-   struct obd_info oinfo = { };
+   struct obd_info oinfo = {
+   .oi_osfs = osfs,
+   .oi_flags = flags,
+   };
int rc = 0;
 
-   set =  ptlrpc_prep_set();
+   set = ptlrpc_prep_set();
if (!set)
return -ENOMEM;
 
-   oinfo.oi_osfs = osfs;
-   oinfo.oi_flags = flags;
rc = obd_statfs_async(exp, , max_age, set);
 

[PATCH 38/41] staging: lustre: mdc: add max modify RPCs in flight variable

2016-10-02 Thread James Simmons
From: Gregoire Pichon 

This patch introduces the maximum modify RPCs in flight variable of
a mdc client obd device. Its value is set from connection flag and
and connection data. It can later be tuned through the
max_mod_rpcs_in_flight procfs file.

Signed-off-by: Gregoire Pichon 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5319
Reviewed-on: http://review.whamcloud.com/14153
Reviewed-by: Andreas Dilger 
Reviewed-by: Dmitry Eremin 
Reviewed-by: Mike Pershin 
Reviewed-by: Alex Zhuravlev 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h   |7 +++
 drivers/staging/lustre/lustre/include/obd_class.h |1 +
 drivers/staging/lustre/lustre/mdc/lproc_mdc.c |   38 ++
 drivers/staging/lustre/lustre/mdc/mdc_request.c   |4 ++
 drivers/staging/lustre/lustre/obdclass/genops.c   |   57 +
 drivers/staging/lustre/lustre/ptlrpc/import.c |   11 
 6 files changed, 118 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 5fa5838..a977388 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -318,6 +318,13 @@ struct client_obd {
struct mdc_rpc_lock *cl_rpc_lock;
struct mdc_rpc_lock *cl_close_lock;
 
+   /* modify rpcs in flight
+* currently used for metadata only
+*/
+   spinlock_t   cl_mod_rpcs_lock;
+   u16  cl_max_mod_rpcs_in_flight;
+
+
/* mgc datastruct */
atomic_t cl_mgc_refcount;
struct obd_export   *cl_mgc_mgsexp;
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index e6ae4a0..7d8f062 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -100,6 +100,7 @@ int obd_get_request_slot(struct client_obd *cli);
 void obd_put_request_slot(struct client_obd *cli);
 __u32 obd_get_max_rpcs_in_flight(struct client_obd *cli);
 int obd_set_max_rpcs_in_flight(struct client_obd *cli, __u32 max);
+int obd_set_max_mod_rpcs_in_flight(struct client_obd *cli, u16 max);
 
 struct llog_handle;
 struct llog_rec_hdr;
diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c 
b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
index fca9450..5fdee9e 100644
--- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
+++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
@@ -73,6 +73,43 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
 }
 LUSTRE_RW_ATTR(max_rpcs_in_flight);
 
+static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj,
+  struct attribute *attr,
+  char *buf)
+{
+   struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+   u16 max;
+   int len;
+
+   max = dev->u.cli.cl_max_mod_rpcs_in_flight;
+   len = sprintf(buf, "%hu\n", max);
+
+   return len;
+}
+
+static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj,
+   struct attribute *attr,
+   const char *buffer,
+   size_t count)
+{
+   struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+   u16 val;
+   int rc;
+
+   rc = kstrtou16(buffer, 10, );
+   if (rc)
+   return rc;
+
+   rc = obd_set_max_mod_rpcs_in_flight(>u.cli, val);
+   if (rc)
+   count = rc;
+
+   return count;
+}
+LUSTRE_RW_ATTR(max_mod_rpcs_in_flight);
+
 LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
 
 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
@@ -117,6 +154,7 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
 
 static struct attribute *mdc_attrs[] = {
_attr_max_rpcs_in_flight.attr,
+   _attr_max_mod_rpcs_in_flight.attr,
_attr_max_pages_per_rpc.attr,
NULL,
 };
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index ac04bf3..af373af 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -2634,8 +2634,12 @@ static int mdc_setup(struct obd_device *obd, struct 
lustre_cfg *cfg)
if (rc) {
mdc_cleanup(obd);
CERROR("failed to setup llogging subsystems\n");
+   return rc;
}
 
+   spin_lock_init(>cl_mod_rpcs_lock);
+   cli->cl_max_mod_rpcs_in_flight = OBD_MAX_RIF_DEFAULT - 1;
+
return rc;
 
 err_close_lock:
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c 
b/drivers/staging/lustre/lustre/obdclass/genops.c
index cf8bb2a..62e6636 100644
--- 

[PATCH 33/41] staging: lustre: lov: use obd_get_info() to get def/max LOV EA sizes

2016-10-02 Thread James Simmons
From: John L. Hammond 

Use obd_get_info() to get the default and maximum LOV EA sizes (along
with maximum cookiesize) from LOV. Remove the then unused function
obd_size_diskmd() and the unused get info key KEY_LOVDESC. When
computing the maximum LOV EA size use the active OST count
(ld_active_tgt_count) rather than the OST count (ld_tgt_count).

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13695
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|1 -
 drivers/staging/lustre/lustre/include/obd_class.h  |6 ---
 drivers/staging/lustre/lustre/llite/lcommon_misc.c |   34 ++--
 drivers/staging/lustre/lustre/llite/llite_lib.c|   10 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c|   24 +++--
 5 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 4691121..5fa5838 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -667,7 +667,6 @@ enum obd_cleanup_stage {
 #define KEY_INTERMDS   "inter_mds"
 #define KEY_LAST_ID "last_id"
 #define KEY_LAST_FID   "last_fid"
-#define KEY_LOVDESC "lovdesc"
 #define KEY_MAX_EASIZE "max_easize"
 #define KEY_DEFAULT_EASIZE "default_easize"
 #define KEY_MGSSEC   "mgssec"
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index a27dbc8..e6ae4a0 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -628,12 +628,6 @@ static inline int obd_packmd(struct obd_export *exp,
return rc;
 }
 
-static inline int obd_size_diskmd(struct obd_export *exp,
- struct lov_stripe_md *mem_src)
-{
-   return obd_packmd(exp, NULL, mem_src);
-}
-
 static inline int obd_free_diskmd(struct obd_export *exp,
  struct lov_mds_md **disk_tgt)
 {
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c 
b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
index 4562643..1558b55 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c
@@ -47,29 +47,29 @@
  */
 int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
 {
-   struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC_V3 };
-   __u32 valsize = sizeof(struct lov_desc);
-   int rc, easize, def_easize;
-   struct lov_desc desc;
-   __u16 stripes, def_stripes;
-
-   rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC,
- , );
+   u32 val_size, max_easize, def_easize;
+   int rc;
+
+   val_size = sizeof(max_easize);
+   rc = obd_get_info(NULL, dt_exp, sizeof(KEY_MAX_EASIZE), KEY_MAX_EASIZE,
+ _size, _easize);
if (rc)
return rc;
 
-   stripes = min_t(__u32, desc.ld_tgt_count, LOV_MAX_STRIPE_COUNT);
-   lsm.lsm_stripe_count = stripes;
-   easize = obd_size_diskmd(dt_exp, );
-
-   def_stripes = min_t(__u32, desc.ld_default_stripe_count,
-   LOV_MAX_STRIPE_COUNT);
-   lsm.lsm_stripe_count = def_stripes;
-   def_easize = obd_size_diskmd(dt_exp, );
+   val_size = sizeof(def_easize);
+   rc = obd_get_info(NULL, dt_exp, sizeof(KEY_DEFAULT_EASIZE),
+ KEY_DEFAULT_EASIZE, _size, _easize);
+   if (rc)
+   return rc;
 
-   CDEBUG(D_HA, "updating def/max_easize: %d/%d\n", def_easize, easize);
+   /*
+* default cookiesize is 0 because from 2.4 server doesn't send
+* llog cookies to client.
+*/
+   CDEBUG(D_HA, "updating def/max_easize: %d/%d\n",
+  def_easize, max_easize);
 
-   rc = md_init_ea_size(md_exp, easize, def_easize);
+   rc = md_init_ea_size(md_exp, max_easize, def_easize);
return rc;
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 25a06f8..84d5556 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -560,7 +560,15 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize)
 {
int size, rc;
 
-   *lmmsize = obd_size_diskmd(sbi->ll_dt_exp, NULL);
+   size = sizeof(*lmmsize);
+   rc = obd_get_info(NULL, sbi->ll_dt_exp, sizeof(KEY_MAX_EASIZE),
+ KEY_MAX_EASIZE, , lmmsize);
+   if (rc) {
+   CERROR("%s: cannot get max LOV EA size: rc = %d\n",
+  sbi->ll_dt_exp->exp_obd->obd_name, rc);
+   return rc;
+   }
+

[PATCH 39/41] staging: lustre: osc: remove remaining bits for capa support

2016-10-02 Thread James Simmons
From: John L. Hammond 

With capa support removed from the OSC layer a few more bits
can be cleaned up. Convert the OBD getattr and setattr paths
to use struct obdo rather than struct obd_info. Remove
the oi_policy, oi_oa, and oi_capa members from struct obd_info.

Signed-off-by: John L. Hammond 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3105
Reviewed-on: http://review.whamcloud.com/14640
Reviewed-by: Andreas Dilger 
Reviewed-by: Alex Zhuravlev 
Reviewed-by: James Simmons 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|   13 +
 drivers/staging/lustre/lustre/include/obd_class.h  |   17 
 drivers/staging/lustre/lustre/llite/vvp_internal.h |1 -
 drivers/staging/lustre/lustre/lov/lov_obd.c|7 ++-
 drivers/staging/lustre/lustre/lov/lov_request.c|2 -
 .../staging/lustre/lustre/obdecho/echo_client.c|   12 +
 .../staging/lustre/lustre/osc/osc_cl_internal.h|1 -
 drivers/staging/lustre/lustre/osc/osc_internal.h   |6 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |   11 +
 drivers/staging/lustre/lustre/osc/osc_request.c|   45 ++--
 10 files changed, 46 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index a977388..f63336f 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -126,17 +126,10 @@ typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
 
 /* obd info for a particular level (lov, osc). */
 struct obd_info {
-   /* Flags used for set request specific flags:
-  - while lock handling, the flags obtained on the enqueue
-  request are set here.
-  - while stats, the flags used for control delay/resend.
-  - while setattr, the flags used for distinguish punch operation
-*/
+   /* OBD_STATFS_* flags */
__u64  oi_flags;
/* lsm data specific for every OSC. */
struct lov_stripe_md   *oi_md;
-   /* obdo data specific for every OSC, if needed at all. */
-   struct obdo *oi_oa;
/* statfs data specific for every OSC, if needed at all. */
struct obd_statfs  *oi_osfs;
/* An update callback which is called to update some data on upper
@@ -871,9 +864,9 @@ struct obd_ops {
int (*destroy)(const struct lu_env *env, struct obd_export *exp,
   struct obdo *oa);
int (*setattr)(const struct lu_env *, struct obd_export *exp,
-  struct obd_info *oinfo);
+  struct obdo *oa);
int (*getattr)(const struct lu_env *env, struct obd_export *exp,
-  struct obd_info *oinfo);
+  struct obdo *oa);
int (*preprw)(const struct lu_env *env, int cmd,
  struct obd_export *exp, struct obdo *oa, int objcount,
  struct obd_ioobj *obj, struct niobuf_remote *remote,
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index 7d8f062..0eaea54 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -705,26 +705,26 @@ static inline int obd_destroy(const struct lu_env *env, 
struct obd_export *exp,
 }
 
 static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp,
- struct obd_info *oinfo)
+ struct obdo *oa)
 {
int rc;
 
EXP_CHECK_DT_OP(exp, getattr);
EXP_COUNTER_INCREMENT(exp, getattr);
 
-   rc = OBP(exp->exp_obd, getattr)(env, exp, oinfo);
+   rc = OBP(exp->exp_obd, getattr)(env, exp, oa);
return rc;
 }
 
 static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp,
- struct obd_info *oinfo)
+ struct obdo *oa)
 {
int rc;
 
EXP_CHECK_DT_OP(exp, setattr);
EXP_COUNTER_INCREMENT(exp, setattr);
 
-   rc = OBP(exp->exp_obd, setattr)(env, exp, oinfo);
+   rc = OBP(exp->exp_obd, setattr)(env, exp, oa);
return rc;
 }
 
@@ -991,15 +991,16 @@ static inline int obd_statfs_rqset(struct obd_export *exp,
   __u32 flags)
 {
struct ptlrpc_request_set *set = NULL;
-   struct obd_info oinfo = { };
+   struct obd_info oinfo = {
+   .oi_osfs = osfs,
+   .oi_flags = flags,
+   };
int rc = 0;
 
-   set =  ptlrpc_prep_set();
+   set = ptlrpc_prep_set();
if (!set)
return -ENOMEM;
 
-   oinfo.oi_osfs = osfs;
-   oinfo.oi_flags = flags;
rc = obd_statfs_async(exp, , max_age, set);
if (rc == 0)
rc = ptlrpc_set_wait(set);
diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h 

[PATCH 21/41] staging: lustre: mdc: Removed unneeded NULL check

2016-10-02 Thread James Simmons
From: Henri Doreau 

Do not bother checking the return value of changelog_kuc_hdr()
against NULL since this value was dereferenced earlier.

Signed-off-by: Henri Doreau 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4189
Reviewed-on: http://review.whamcloud.com/12919
Reviewed-by: John L. Hammond 
Reviewed-by: Faccini Bruno 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/mdc/mdc_request.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index d996326..206f5d0 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1867,10 +1867,8 @@ static int mdc_changelog_send_thread(void *csdata)
 
/* Send EOF no matter what our result */
kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch), cs->cs_flags);
-   if (kuch) {
-   kuch->kuc_msgtype = CL_EOF;
-   libcfs_kkuc_msg_put(cs->cs_fp, kuch);
-   }
+   kuch->kuc_msgtype = CL_EOF;
+   libcfs_kkuc_msg_put(cs->cs_fp, kuch);
 
 out:
fput(cs->cs_fp);
-- 
1.7.1



[PATCH 37/41] staging: lustre: lov: copy_to_user uses wrong casting

2016-10-02 Thread James Simmons
With certain version of gcc lov_obd.c failes to compile
with the following warning.

In function copy_to_user,
inlined from lov_iocontrol at
lustre/lustre/lov/lov_obd.c:1168:
./arch/x86/include/asm/uaccess.h:735: error: call to
__copy_to_user_overflow declared with attribute warning:
copy_to_user() buffer size is not probably correct

In lov_iocontrol the data was being casted to int instead
of the required unsigned long. This patch changes the cast
to what is needed for copy_to_user.

Signed-off-by: James Simmons 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6302
Reviewed-on: http://review.whamcloud.com/14613
Reviewed-by: frank zago 
Reviewed-by: Dmitry Eremin 
Reviewed-by: John L. Hammond 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/lov/lov_obd.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c 
b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 473071c..18cb92d 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1085,8 +1085,8 @@ static int lov_iocontrol(unsigned int cmd, struct 
obd_export *exp, int len,
 
/* copy UUID */
if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd),
-min((int)data->ioc_plen2,
-(int)sizeof(struct obd_uuid
+min_t(unsigned long, data->ioc_plen2,
+  sizeof(struct obd_uuid
return -EFAULT;
 
memcpy(, data->ioc_inlbuf1, sizeof(__u32));
@@ -1099,8 +1099,8 @@ static int lov_iocontrol(unsigned int cmd, struct 
obd_export *exp, int len,
if (rc)
return rc;
if (copy_to_user(data->ioc_pbuf1, _buf,
-min((int)data->ioc_plen1,
-(int)sizeof(stat_buf
+min_t(unsigned long, data->ioc_plen1,
+  sizeof(stat_buf
return -EFAULT;
break;
}
-- 
1.7.1



[PATCH 29/41] staging: lustre: ptlrpc: Move NRS structures out of lustre_net.h

2016-10-02 Thread James Simmons
From: Chris Horn 

NRS specific structures are not needed in the rest of the PtlRPC code.
It is more appropriate for these structures to be defined in a
separate header. This commit creates a lustre_nrs.h header for the
generic NRS structures, and policy-specific headers for the various
NRS policies.

Signed-off-by: Chris Horn 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2667
Reviewed-on: http://review.whamcloud.com/13966
Reviewed-by: Henri Doreau 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/lustre_net.h |  712 +---
 drivers/staging/lustre/lustre/include/lustre_nrs.h |  717 
 .../lustre/lustre/include/lustre_nrs_fifo.h|   70 ++
 3 files changed, 788 insertions(+), 711 deletions(-)
 create mode 100644 drivers/staging/lustre/lustre/include/lustre_nrs.h
 create mode 100644 drivers/staging/lustre/lustre/include/lustre_nrs_fifo.h

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h 
b/drivers/staging/lustre/lustre/include/lustre_net.h
index ab80330..7302238 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -515,717 +515,7 @@ struct lu_env;
 
 struct ldlm_lock;
 
-/**
- * \defgroup nrs Network Request Scheduler
- * @{
- */
-struct ptlrpc_nrs_policy;
-struct ptlrpc_nrs_resource;
-struct ptlrpc_nrs_request;
-
-/**
- * NRS control operations.
- *
- * These are common for all policies.
- */
-enum ptlrpc_nrs_ctl {
-   /**
-* Not a valid opcode.
-*/
-   PTLRPC_NRS_CTL_INVALID,
-   /**
-* Activate the policy.
-*/
-   PTLRPC_NRS_CTL_START,
-   /**
-* Reserved for multiple primary policies, which may be a possibility
-* in the future.
-*/
-   PTLRPC_NRS_CTL_STOP,
-   /**
-* Policies can start using opcodes from this value and onwards for
-* their own purposes; the assigned value itself is arbitrary.
-*/
-   PTLRPC_NRS_CTL_1ST_POL_SPEC = 0x20,
-};
-
-/**
- * ORR policy operations
- */
-enum nrs_ctl_orr {
-   NRS_CTL_ORR_RD_QUANTUM = PTLRPC_NRS_CTL_1ST_POL_SPEC,
-   NRS_CTL_ORR_WR_QUANTUM,
-   NRS_CTL_ORR_RD_OFF_TYPE,
-   NRS_CTL_ORR_WR_OFF_TYPE,
-   NRS_CTL_ORR_RD_SUPP_REQ,
-   NRS_CTL_ORR_WR_SUPP_REQ,
-};
-
-/**
- * NRS policy operations.
- *
- * These determine the behaviour of a policy, and are called in response to
- * NRS core events.
- */
-struct ptlrpc_nrs_pol_ops {
-   /**
-* Called during policy registration; this operation is optional.
-*
-* \param[in,out] policy The policy being initialized
-*/
-   int (*op_policy_init)(struct ptlrpc_nrs_policy *policy);
-   /**
-* Called during policy unregistration; this operation is optional.
-*
-* \param[in,out] policy The policy being unregistered/finalized
-*/
-   void(*op_policy_fini)(struct ptlrpc_nrs_policy *policy);
-   /**
-* Called when activating a policy via lprocfs; policies allocate and
-* initialize their resources here; this operation is optional.
-*
-* \param[in,out] policy The policy being started
-*
-* \see nrs_policy_start_locked()
-*/
-   int (*op_policy_start)(struct ptlrpc_nrs_policy *policy);
-   /**
-* Called when deactivating a policy via lprocfs; policies deallocate
-* their resources here; this operation is optional
-*
-* \param[in,out] policy The policy being stopped
-*
-* \see nrs_policy_stop0()
-*/
-   void(*op_policy_stop)(struct ptlrpc_nrs_policy *policy);
-   /**
-* Used for policy-specific operations; i.e. not generic ones like
-* \e PTLRPC_NRS_CTL_START and \e PTLRPC_NRS_CTL_GET_INFO; analogous
-* to an ioctl; this operation is optional.
-*
-* \param[in,out]policy The policy carrying out operation \a opc
-* \param[in] opcThe command operation being carried out
-* \param[in,out] argAn generic buffer for communication between the
-*   user and the control operation
-*
-* \retval -ve error
-* \retval   0 success
-*
-* \see ptlrpc_nrs_policy_control()
-*/
-   int (*op_policy_ctl)(struct ptlrpc_nrs_policy *policy,
-enum ptlrpc_nrs_ctl opc, void *arg);
-
-   /**
-* Called when obtaining references to the resources of the resource
-* hierarchy for a request that has arrived for handling at the PTLRPC
-* service. Policies should return -ve for requests they do not wish
-* to handle. This operation is mandatory.
-*
-* \param[in,out] policy  The policy we're getting resources for.
-* \param[in,out] nrq The request we are 

[PATCH 35/41] staging: lustre: hsm: Use file lease to implement migration

2016-10-02 Thread James Simmons
From: Henri Doreau 

Implement non-blocking migration based on exclusive open instead of
group lock. Implemented exclusive close operation to atomically put
a lease, swap two layouts and close a file. This allows race-free
migrations.

Make the caller responsible for retrying on failure (EBUSY, EAGAIN)
in non-blocking mode.

In blocking mode, allow applications to trigger layout swaps using a
grouplock they already own, to prevent race conditions between the
actual data copy and the layout swap. Updated lfs accordingly. File
leases are also taken in blocking mode, so that lfs migrate can issue
a warning if an application attempts to open a file that is being
migrated and gets blocked.

Timestamps (atime/mtime) are set from userland, after the layout swap
is performed, to prevent conflicts with the grouplock.

lli_trunc_sem is taken/released in the vvp_io layer, under the DLM
lock. This re-ordering fixes the original issue between truncate and
migrate.

Signed-off-by: Henri Doreau 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4840
Reviewed-on: http://review.whamcloud.com/10013
Reviewed-by: John L. Hammond 
Reviewed-by: frank zago 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 .../lustre/lustre/include/lustre/lustre_idl.h  |5 +-
 .../lustre/lustre/include/lustre/lustre_user.h |1 +
 .../lustre/lustre/include/lustre_req_layout.h  |2 +-
 drivers/staging/lustre/lustre/llite/file.c |  231 
 drivers/staging/lustre/lustre/llite/llite_lib.c|4 -
 drivers/staging/lustre/lustre/llite/vvp_io.c   |   82 +---
 drivers/staging/lustre/lustre/mdc/mdc_lib.c|   34 ++--
 drivers/staging/lustre/lustre/mdc/mdc_request.c|7 +-
 drivers/staging/lustre/lustre/ptlrpc/layout.c  |   10 +-
 9 files changed, 235 insertions(+), 141 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 5d2f845..7de8098 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -1703,7 +1703,9 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 
lmm_magic)
 /* OBD_MD_FLRMTRGETFACL (0x0008ULL) lfs rgetfacl, obsolete */
 
 #define OBD_MD_FLDATAVERSION (0x0010ULL) /* iversion sum */
-#define OBD_MD_FLRELEASED(0x0020ULL) /* file released */
+#define OBD_MD_CLOSE_INTENT_EXECED (0x0020ULL) /* close intent
+   * executed
+   */
 
 #define OBD_MD_DEFAULT_MEA   (0x0040ULL) /* default MEA */
 
@@ -2235,6 +2237,7 @@ enum mds_op_bias {
MDS_OWNEROVERRIDE   = 1 << 11,
MDS_HSM_RELEASE = 1 << 12,
MDS_RENAME_MIGRATE  = BIT(13),
+   MDS_CLOSE_LAYOUT_SWAP   = BIT(14),
 };
 
 /* instance of mdt_reint_rec */
diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h 
b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
index 856e2f9..579ef14 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
@@ -650,6 +650,7 @@ struct if_quotactl {
 #define SWAP_LAYOUTS_CHECK_DV2 (1 << 1)
 #define SWAP_LAYOUTS_KEEP_MTIME(1 << 2)
 #define SWAP_LAYOUTS_KEEP_ATIME(1 << 3)
+#define SWAP_LAYOUTS_CLOSE BIT(4)
 
 /* Swap XATTR_NAME_HSM as well, only on the MDT so far */
 #define SWAP_LAYOUTS_MDS_HSM   (1 << 31)
diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h 
b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
index 78857b3..7657132 100644
--- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h
+++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h
@@ -148,7 +148,7 @@ extern struct req_format RQF_MDS_GETATTR;
  */
 extern struct req_format RQF_MDS_GETATTR_NAME;
 extern struct req_format RQF_MDS_CLOSE;
-extern struct req_format RQF_MDS_RELEASE_CLOSE;
+extern struct req_format RQF_MDS_INTENT_CLOSE;
 extern struct req_format RQF_MDS_CONNECT;
 extern struct req_format RQF_MDS_DISCONNECT;
 extern struct req_format RQF_MDS_GET_INFO;
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 9bf50bf..b9cadd9 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -113,10 +113,19 @@ out:
   0, 0, LUSTRE_OPC_ANY, NULL);
 }
 
+/**
+ * Perform a close, possibly with a bias.
+ * The meaning of "data" depends on the value of "bias".
+ *
+ * If \a bias is MDS_HSM_RELEASE then \a data is a pointer to the data version.
+ * If \a bias is MDS_CLOSE_LAYOUT_SWAP then \a data is a pointer to the inode 
to
+ * swap layouts with.
+ */
 static int 

[PATCH 27/41] staging: lustre: llite: add cl_object_maxbytes()

2016-10-02 Thread James Simmons
From: John L. Hammond 

Add cl_object_maxbytes() to return the maximum supported size of a
cl_object. Remove the lli_maxbytes member from struct
ll_inode_info. Change the lsm_maxbytes member of struct lov_stripe_md
from __u64 to loff_t. Correct the computation of lsm_maxbytes in the
released layout case.

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13694
Reviewed-by: Andreas Dilger 
Reviewed-by: James Simmons 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/cl_object.h  |5 +
 drivers/staging/lustre/lustre/include/obd.h|2 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |   10 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|8 +-
 drivers/staging/lustre/lustre/lov/lov_ea.c |  191 +---
 drivers/staging/lustre/lustre/lov/lov_object.c |   17 ++
 drivers/staging/lustre/lustre/obdclass/cl_object.c |   15 ++
 7 files changed, 130 insertions(+), 118 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index b80539d..dfef4bc 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -431,6 +431,10 @@ struct cl_object_operations {
 */
int (*coo_layout_get)(const struct lu_env *env, struct cl_object *obj,
  struct cl_layout *layout);
+   /**
+* Get maximum size of the object.
+*/
+   loff_t (*coo_maxbytes)(struct cl_object *obj);
 };
 
 /**
@@ -2227,6 +2231,7 @@ int cl_object_fiemap(const struct lu_env *env, struct 
cl_object *obj,
 size_t *buflen);
 int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj,
 struct cl_layout *cl);
+loff_t cl_object_maxbytes(struct cl_object *obj);
 
 /**
  * Returns true, iff \a o0 and \a o1 are slices of the same object.
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index f254d88..8372deb 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -88,7 +88,7 @@ struct lov_stripe_md {
/* maximum possible file size, might change as OSTs status changes,
 * e.g. disconnected, deactivated
 */
-   __u64   lsm_maxbytes;
+   loff_t  lsm_maxbytes;
struct ost_id   lsm_oi;
__u32   lsm_magic;
__u32   lsm_stripe_size;
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 913e532..cf95a72 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -185,7 +185,6 @@ struct ll_inode_info {
struct {
struct mutexlli_size_mutex;
char   *lli_symlink_name;
-   __u64   lli_maxbytes;
/*
 * struct rw_semaphore {
 *signed long   count; // align d.d_def_acl
@@ -988,9 +987,14 @@ static inline struct lu_fid *ll_inode2fid(struct inode 
*inode)
return fid;
 }
 
-static inline __u64 ll_file_maxbytes(struct inode *inode)
+static inline loff_t ll_file_maxbytes(struct inode *inode)
 {
-   return ll_i2info(inode)->lli_maxbytes;
+   struct cl_object *obj = ll_i2info(inode)->lli_clob;
+
+   if (!obj)
+   return MAX_LFS_FILESIZE;
+
+   return min_t(loff_t, cl_object_maxbytes(obj), MAX_LFS_FILESIZE);
 }
 
 /* llite/xattr.c */
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 5400cbe..25a06f8 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -785,7 +785,6 @@ void ll_lli_init(struct ll_inode_info *lli)
 {
lli->lli_inode_magic = LLI_INODE_MAGIC;
lli->lli_flags = 0;
-   lli->lli_maxbytes = MAX_LFS_FILESIZE;
spin_lock_init(>lli_lock);
lli->lli_posix_acl = NULL;
/* Do not set lli_fid, it has been initialized already. */
@@ -1685,14 +1684,9 @@ int ll_update_inode(struct inode *inode, struct 
lustre_md *md)
struct ll_sb_info *sbi = ll_i2sbi(inode);
 
LASSERT((lsm != NULL) == ((body->mbo_valid & OBD_MD_FLEASIZE) != 0));
-   if (lsm) {
+   if (lsm)
cl_file_inode_init(inode, md);
 
-   lli->lli_maxbytes = lsm->lsm_maxbytes;
-   if (lli->lli_maxbytes > MAX_LFS_FILESIZE)
-   

[PATCH 40/41] staging: lustre: lov: move LSM to LOV layer

2016-10-02 Thread James Simmons
From: John L. Hammond 

Move the definition of struct lov_stripe_md along with supporting
functions from obd.h to lov_internal.h. Remove the unused functions
obd_packmd() and obd_free_diskmd(). Simplify lov_obd_packmd()
according to the reduced use cases and rename it lov_packmd().

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13696
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|   77 +--
 drivers/staging/lustre/lustre/include/obd_class.h  |   38 -
 .../staging/lustre/lustre/llite/llite_internal.h   |2 -
 drivers/staging/lustre/lustre/llite/vvp_internal.h |1 -
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|  105 --
 drivers/staging/lustre/lustre/lov/lov_ea.c |4 +-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |   80 +++-
 drivers/staging/lustre/lustre/lov/lov_obd.c|9 --
 drivers/staging/lustre/lustre/lov/lov_pack.c   |  145 +---
 drivers/staging/lustre/lustre/mdc/mdc_request.c|8 -
 drivers/staging/lustre/lustre/osc/osc_request.c|   63 -
 11 files changed, 118 insertions(+), 414 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index f63336f..ebb3012 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -73,53 +73,7 @@ static inline void loi_init(struct lov_oinfo *loi)
 {
 }
 
-/*
- * If we are unable to get the maximum object size from the OST in
- * ocd_maxbytes using OBD_CONNECT_MAXBYTES, then we fall back to using
- * the old maximum object size from ext3.
- */
-#define LUSTRE_EXT3_STRIPE_MAXBYTES 0x1fff000ULL
-
-struct lov_stripe_md {
-   atomic_t lsm_refc;
-   spinlock_t  lsm_lock;
-   pid_t   lsm_lock_owner; /* debugging */
-
-   /* maximum possible file size, might change as OSTs status changes,
-* e.g. disconnected, deactivated
-*/
-   loff_t  lsm_maxbytes;
-   struct ost_id   lsm_oi;
-   __u32   lsm_magic;
-   __u32   lsm_stripe_size;
-   __u32   lsm_pattern;/* striping pattern (RAID0, RAID1) */
-   __u16   lsm_stripe_count;
-   __u16   lsm_layout_gen;
-   charlsm_pool_name[LOV_MAXPOOLNAME + 1];
-   struct lov_oinfo *lsm_oinfo[0];
-};
-
-static inline bool lsm_is_released(struct lov_stripe_md *lsm)
-{
-   return !!(lsm->lsm_pattern & LOV_PATTERN_F_RELEASED);
-}
-
-static inline bool lsm_has_objects(struct lov_stripe_md *lsm)
-{
-   if (!lsm)
-   return false;
-   if (lsm_is_released(lsm))
-   return false;
-   return true;
-}
-
-static inline int lov_stripe_md_size(unsigned int stripe_count)
-{
-   struct lov_stripe_md lsm;
-
-   return sizeof(lsm) + stripe_count * sizeof(lsm.lsm_oinfo[0]);
-}
-
+struct lov_stripe_md;
 struct obd_info;
 
 typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
@@ -854,8 +808,6 @@ struct obd_ops {
  struct obd_statfs *osfs, __u64 max_age, __u32 flags);
int (*statfs_async)(struct obd_export *exp, struct obd_info *oinfo,
__u64 max_age, struct ptlrpc_request_set *set);
-   int (*packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
- struct lov_stripe_md *mem_src);
int (*unpackmd)(struct obd_export *exp,
struct lov_stripe_md **mem_tgt,
struct lov_mds_md *disk_src, int disk_len);
@@ -1033,33 +985,6 @@ struct md_ops {
 */
 };
 
-struct lsm_operations {
-   void (*lsm_free)(struct lov_stripe_md *);
-   void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, u64 *,
-   u64 *);
-   void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, u64 *,
-u64 *);
-   int (*lsm_lmm_verify)(struct lov_mds_md *lmm, int lmm_bytes,
- __u16 *stripe_count);
-   int (*lsm_unpackmd)(struct lov_obd *lov, struct lov_stripe_md *lsm,
-   struct lov_mds_md *lmm);
-};
-
-extern const struct lsm_operations lsm_v1_ops;
-extern const struct lsm_operations lsm_v3_ops;
-static inline const struct lsm_operations *lsm_op_find(int magic)
-{
-   switch (magic) {
-   case LOV_MAGIC_V1:
-  return _v1_ops;
-   case LOV_MAGIC_V3:
-  return _v3_ops;
-   default:
-  CERROR("Cannot recognize lsm_magic %08x\n", magic);
-  return NULL;
-   }
-}
-
 static inline struct md_open_data 

[PATCH 36/41] staging: lustre: ldlm: interval tree search in ldlm_lock_match()

2016-10-02 Thread James Simmons
From: Vitaly Fertman 

replace the linear search by interval_tree one for granted list
in ldlm_lock_match()

Signed-off-by: Vitaly Fertman 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5739
Xyratex-bug-id: MRP-2089
Reviewed-on: http://review.whamcloud.com/12294
Reviewed-by: Andreas Dilger 
Reviewed-by: Jinshan Xiong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |  249 
 1 files changed, 171 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 22b4a52..f2044ec 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1043,88 +1043,173 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct 
list_head *work_list)
 }
 
 /**
- * Search for a lock with given properties in a queue.
+ * Describe the overlap between two locks.  itree_overlap_cb data.
+ */
+struct lock_match_data {
+   struct ldlm_lock*lmd_old;
+   struct ldlm_lock*lmd_lock;
+   enum ldlm_mode  *lmd_mode;
+   ldlm_policy_data_t  *lmd_policy;
+   __u64lmd_flags;
+   int  lmd_unref;
+};
+
+/**
+ * Check if the given @lock meets the criteria for a match.
+ * A reference on the lock is taken if matched.
  *
- * \retval a referenced lock or NULL.  See the flag descriptions below, in the
- * comment above ldlm_lock_match
+ * \param lock test-against this lock
+ * \param data parameters
  */
-static struct ldlm_lock *search_queue(struct list_head *queue,
- enum ldlm_mode *mode,
- ldlm_policy_data_t *policy,
- struct ldlm_lock *old_lock,
- __u64 flags, int unref)
+static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data)
 {
-   struct ldlm_lock *lock;
-   struct list_head   *tmp;
+   ldlm_policy_data_t *lpol = >l_policy_data;
+   enum ldlm_mode match;
 
-   list_for_each(tmp, queue) {
-   enum ldlm_mode match;
+   if (lock == data->lmd_old)
+   return INTERVAL_ITER_STOP;
 
-   lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+   /*
+* Check if this lock can be matched.
+* Used by LU-2919(exclusive open) for open lease lock
+*/
+   if (ldlm_is_excl(lock))
+   return INTERVAL_ITER_CONT;
 
-   if (lock == old_lock)
-   break;
+   /*
+* llite sometimes wants to match locks that will be
+* canceled when their users drop, but we allow it to match
+* if it passes in CBPENDING and the lock still has users.
+* this is generally only going to be used by children
+* whose parents already hold a lock so forward progress
+* can still happen.
+*/
+   if (ldlm_is_cbpending(lock) &&
+   !(data->lmd_flags & LDLM_FL_CBPENDING))
+   return INTERVAL_ITER_CONT;
 
-   /* Check if this lock can be matched.
-* Used by LU-2919(exclusive open) for open lease lock
-*/
-   if (ldlm_is_excl(lock))
-   continue;
+   if (!data->lmd_unref && ldlm_is_cbpending(lock) &&
+   !lock->l_readers && !lock->l_writers)
+   return INTERVAL_ITER_CONT;
 
-   /* llite sometimes wants to match locks that will be
-* canceled when their users drop, but we allow it to match
-* if it passes in CBPENDING and the lock still has users.
-* this is generally only going to be used by children
-* whose parents already hold a lock so forward progress
-* can still happen.
-*/
-   if (ldlm_is_cbpending(lock) && !(flags & LDLM_FL_CBPENDING))
-   continue;
-   if (!unref && ldlm_is_cbpending(lock) &&
-   lock->l_readers == 0 && lock->l_writers == 0)
-   continue;
+   if (!(lock->l_req_mode & *data->lmd_mode))
+   return INTERVAL_ITER_CONT;
+   match = lock->l_req_mode;
 
-   if (!(lock->l_req_mode & *mode))
-   continue;
-   match = lock->l_req_mode;
-
-   if (lock->l_resource->lr_type == LDLM_EXTENT &&
-   (lock->l_policy_data.l_extent.start >
-policy->l_extent.start ||
-lock->l_policy_data.l_extent.end < policy->l_extent.end))
-   continue;
+   switch (lock->l_resource->lr_type) {
+   case LDLM_EXTENT:
+

[PATCH 23/41] staging: lustre: mgc: MGC should retry for invalid import

2016-10-02 Thread James Simmons
From: wang di 

After http://review.whamcloud.com/#/c/9967/ is landed, mgc does
not wait the import connected(state = FULL), then enqueue and
retrieve config log, which will cause the mount process to fail,
especially if the mgc is shared by multiple targets.
So once mgc enqueue is failed, it will give another chance to
wait the import to recover, if the import comes back in time,
it will try to enqueue again. Otherwise it will use local config log.

Signed-off-by: wang di 
Signed-off-by: Andreas Dilger 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5420
Reviewed-on: http://review.whamcloud.com/11258
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/lustre_ha.h |1 +
 drivers/staging/lustre/lustre/mgc/mgc_request.c   |   85 +++--
 drivers/staging/lustre/lustre/ptlrpc/import.c |3 +-
 3 files changed, 81 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_ha.h 
b/drivers/staging/lustre/lustre/include/lustre_ha.h
index cde7ed7..dec1e99 100644
--- a/drivers/staging/lustre/lustre/include/lustre_ha.h
+++ b/drivers/staging/lustre/lustre/include/lustre_ha.h
@@ -53,6 +53,7 @@ void ptlrpc_activate_import(struct obd_import *imp);
 void ptlrpc_deactivate_import(struct obd_import *imp);
 void ptlrpc_invalidate_import(struct obd_import *imp);
 void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt);
+void ptlrpc_pinger_force(struct obd_import *imp);
 
 /** @} ha */
 
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c 
b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 1a0e59a..7b5ac44 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1552,14 +1552,52 @@ out_free:
return rc;
 }
 
-/** Get a config log from the MGS and process it.
- * This func is called for both clients and servers.
- * Copy the log locally before parsing it if appropriate (non-MGS server)
+static bool mgc_import_in_recovery(struct obd_import *imp)
+{
+   bool in_recovery = true;
+
+   spin_lock(>imp_lock);
+   if (imp->imp_state == LUSTRE_IMP_FULL ||
+   imp->imp_state == LUSTRE_IMP_CLOSED)
+   in_recovery = false;
+   spin_unlock(>imp_lock);
+
+   return in_recovery;
+}
+
+/**
+ * Get a configuration log from the MGS and process it.
+ *
+ * This function is called for both clients and servers to process the
+ * configuration log from the MGS.  The MGC enqueues a DLM lock on the
+ * log from the MGS, and if the lock gets revoked the MGC will be notified
+ * by the lock cancellation callback that the config log has changed,
+ * and will enqueue another MGS lock on it, and then continue processing
+ * the new additions to the end of the log.
+ *
+ * Since the MGC import is not replayable, if the import is being evicted
+ * (rcl == -ESHUTDOWN, \see ptlrpc_import_delay_req()), retry to process
+ * the log until recovery is finished or the import is closed.
+ *
+ * Make a local copy of the log before parsing it if appropriate (non-MGS
+ * server) so that the server can start even when the MGS is down.
+ *
+ * There shouldn't be multiple processes running process_log at once --
+ * sounds like badness.  It actually might be fine, as long as they're not
+ * trying to update from the same log simultaneously, in which case we
+ * should use a per-log semaphore instead of cld_lock.
+ *
+ * \param[in] mgc  MGC device by which to fetch the configuration log
+ * \param[in] cld  log processing state (stored in lock callback data)
+ *
+ * \retval 0 on success
+ * \retval negative errno on failure
  */
 int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld)
 {
struct lustre_handle lockh = { 0 };
__u64 flags = LDLM_FL_NO_LRU;
+   bool retry = false;
int rc = 0, rcl;
 
LASSERT(cld);
@@ -1569,6 +1607,7 @@ int mgc_process_log(struct obd_device *mgc, struct 
config_llog_data *cld)
 * we're not trying to update from the same log
 * simultaneously (in which case we should use a per-log sem.)
 */
+restart:
mutex_lock(>cld_lock);
if (cld->cld_stopping) {
mutex_unlock(>cld_lock);
@@ -1592,10 +1631,42 @@ int mgc_process_log(struct obd_device *mgc, struct 
config_llog_data *cld)
} else {
CDEBUG(D_MGC, "Can't get cfg lock: %d\n", rcl);
 
-   /* mark cld_lostlock so that it will requeue
-* after MGC becomes available.
-*/
-   cld->cld_lostlock = 1;
+   if (rcl == -ESHUTDOWN &&
+   atomic_read(>u.cli.cl_mgc_refcount) > 0 && !retry) {
+   int secs = cfs_time_seconds(obd_timeout);
+   struct obd_import *imp;
+   struct l_wait_info lwi;
+
+   

[PATCH 32/41] staging: lustre: llite: restart short read/write for normal IO

2016-10-02 Thread James Simmons
From: Bobi Jam 

If normal IO got short read/write, we'd restart the IO from where
we've accomplished until we meet EOF or error happens.

Signed-off-by: Bobi Jam 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6389
Reviewed-on: http://review.whamcloud.com/14123
Reviewed-by: Andreas Dilger 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lnet/libcfs/fail.c  |1 +
 .../staging/lustre/lustre/include/obd_support.h|2 +
 drivers/staging/lustre/lustre/llite/file.c |   41 
 drivers/staging/lustre/lustre/llite/vvp_io.c   |   19 -
 4 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/fail.c 
b/drivers/staging/lustre/lnet/libcfs/fail.c
index e4b1a0a..3a9c8dd 100644
--- a/drivers/staging/lustre/lnet/libcfs/fail.c
+++ b/drivers/staging/lustre/lnet/libcfs/fail.c
@@ -113,6 +113,7 @@ int __cfs_fail_check_set(__u32 id, __u32 value, int set)
break;
case CFS_FAIL_LOC_RESET:
cfs_fail_loc = value;
+   atomic_set(_fail_count, 0);
break;
default:
LASSERTF(0, "called with bad set %u\n", set);
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h 
b/drivers/staging/lustre/lustre/include/obd_support.h
index 1233c34..7f3f8cd 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -458,6 +458,8 @@ extern char obd_jobid_var[];
 #define OBD_FAIL_LOV_INIT  0x1403
 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
 #define OBD_FAIL_LLITE_XATTR_ENOMEM0x1405
+#define OBD_FAIL_MAKE_LOVEA_HOLE   0x1406
+#define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
 #define OBD_FAIL_GETATTR_DELAY 0x1409
 
 #define OBD_FAIL_FID_INDIR 0x1501
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 94caf4f..9bf50bf 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -972,9 +972,11 @@ ll_file_io_generic(const struct lu_env *env, struct 
vvp_io_args *args,
 {
struct ll_inode_info *lli = ll_i2info(file_inode(file));
struct ll_file_data  *fd  = LUSTRE_FPRIVATE(file);
+   struct vvp_io *vio = vvp_env_io(env);
struct range_lock range;
struct cl_io *io;
-   ssize_tresult;
+   ssize_t result = 0;
+   int rc = 0;
 
CDEBUG(D_VFSTRACE, "file: %s, type: %d ppos: %llu, count: %zu\n",
   file->f_path.dentry->d_name.name, iot, *ppos, count);
@@ -1010,9 +1012,8 @@ restart:
CDEBUG(D_VFSTRACE, "Range lock [%llu, %llu]\n",
   range.rl_node.in_extent.start,
   range.rl_node.in_extent.end);
-   result = range_lock(>lli_write_tree,
-   );
-   if (result < 0)
+   rc = range_lock(>lli_write_tree, );
+   if (rc < 0)
goto out;
 
range_locked = true;
@@ -1028,7 +1029,7 @@ restart:
LBUG();
}
ll_cl_add(file, env, io);
-   result = cl_io_loop(env, io);
+   rc = cl_io_loop(env, io);
ll_cl_remove(file, env);
if (args->via_io_subtype == IO_NORMAL)
up_read(>lli_trunc_sem);
@@ -1040,24 +1041,26 @@ restart:
}
} else {
/* cl_io_rw_init() handled IO */
-   result = io->ci_result;
+   rc = io->ci_result;
}
 
if (io->ci_nob > 0) {
result = io->ci_nob;
+   count -= io->ci_nob;
*ppos = io->u.ci_wr.wr.crw_pos;
+
+   /* prepare IO restart */
+   if (count > 0 && args->via_io_subtype == IO_NORMAL)
+   args->u.normal.via_iter = vio->vui_iter;
}
-   goto out;
 out:
cl_io_fini(env, io);
-   /* If any bit been read/written (result != 0), we just return
-* short read/write instead of restart io.
-*/
-   if ((result == 0 || result == -ENODATA) && io->ci_need_restart) {
-   CDEBUG(D_VFSTRACE, "Restart %s on %pD from %lld, count:%zu\n",
+
+   if ((!rc || rc == -ENODATA) && count > 0 && io->ci_need_restart) {
+   CDEBUG(D_VFSTRACE, "%s: restart %s from %lld, count:%zu, 
result: %zd\n",
+  file_dentry(file)->d_name.name,
   

[PATCH 28/41] staging: lustre: hsm: make HSM modification requests replayable

2016-10-02 Thread James Simmons
From: Mikhail Pershin 

There are several HSM requests which modify data on server and
reply on Lustre recovery, e.g. they should replay changes in
case of recovery.

Patch allows such requests to be replayed in recovery time and
they are issued from client using mdc_rpc_lock to serialize them
and avoid concurrent last_rcvd update on server.

Signed-off-by: Mikhail Pershin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5939
Reviewed-on: http://review.whamcloud.com/13684
Reviewed-by: Jinshan Xiong 
Reviewed-by: Faccini Bruno 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/mdc/mdc_request.c |   12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 7b9fb90..1d1eaa5 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1505,7 +1505,9 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
 
ptlrpc_request_set_replen(req);
 
-   rc = mdc_queue_wait(req);
+   mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+   rc = ptlrpc_queue_wait(req);
+   mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
 out:
ptlrpc_req_finished(req);
return rc;
@@ -1683,7 +1685,9 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
 
ptlrpc_request_set_replen(req);
 
-   rc = mdc_queue_wait(req);
+   mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+   rc = ptlrpc_queue_wait(req);
+   mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
 out:
ptlrpc_req_finished(req);
return rc;
@@ -1746,7 +1750,9 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 
ptlrpc_request_set_replen(req);
 
-   rc = mdc_queue_wait(req);
+   mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+   rc = ptlrpc_queue_wait(req);
+   mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
 out:
ptlrpc_req_finished(req);
return rc;
-- 
1.7.1



[PATCH 27/41] staging: lustre: llite: add cl_object_maxbytes()

2016-10-02 Thread James Simmons
From: John L. Hammond 

Add cl_object_maxbytes() to return the maximum supported size of a
cl_object. Remove the lli_maxbytes member from struct
ll_inode_info. Change the lsm_maxbytes member of struct lov_stripe_md
from __u64 to loff_t. Correct the computation of lsm_maxbytes in the
released layout case.

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13694
Reviewed-by: Andreas Dilger 
Reviewed-by: James Simmons 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/cl_object.h  |5 +
 drivers/staging/lustre/lustre/include/obd.h|2 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |   10 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|8 +-
 drivers/staging/lustre/lustre/lov/lov_ea.c |  191 +---
 drivers/staging/lustre/lustre/lov/lov_object.c |   17 ++
 drivers/staging/lustre/lustre/obdclass/cl_object.c |   15 ++
 7 files changed, 130 insertions(+), 118 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index b80539d..dfef4bc 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -431,6 +431,10 @@ struct cl_object_operations {
 */
int (*coo_layout_get)(const struct lu_env *env, struct cl_object *obj,
  struct cl_layout *layout);
+   /**
+* Get maximum size of the object.
+*/
+   loff_t (*coo_maxbytes)(struct cl_object *obj);
 };
 
 /**
@@ -2227,6 +2231,7 @@ int cl_object_fiemap(const struct lu_env *env, struct 
cl_object *obj,
 size_t *buflen);
 int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj,
 struct cl_layout *cl);
+loff_t cl_object_maxbytes(struct cl_object *obj);
 
 /**
  * Returns true, iff \a o0 and \a o1 are slices of the same object.
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index f254d88..8372deb 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -88,7 +88,7 @@ struct lov_stripe_md {
/* maximum possible file size, might change as OSTs status changes,
 * e.g. disconnected, deactivated
 */
-   __u64   lsm_maxbytes;
+   loff_t  lsm_maxbytes;
struct ost_id   lsm_oi;
__u32   lsm_magic;
__u32   lsm_stripe_size;
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 913e532..cf95a72 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -185,7 +185,6 @@ struct ll_inode_info {
struct {
struct mutexlli_size_mutex;
char   *lli_symlink_name;
-   __u64   lli_maxbytes;
/*
 * struct rw_semaphore {
 *signed long   count; // align d.d_def_acl
@@ -988,9 +987,14 @@ static inline struct lu_fid *ll_inode2fid(struct inode 
*inode)
return fid;
 }
 
-static inline __u64 ll_file_maxbytes(struct inode *inode)
+static inline loff_t ll_file_maxbytes(struct inode *inode)
 {
-   return ll_i2info(inode)->lli_maxbytes;
+   struct cl_object *obj = ll_i2info(inode)->lli_clob;
+
+   if (!obj)
+   return MAX_LFS_FILESIZE;
+
+   return min_t(loff_t, cl_object_maxbytes(obj), MAX_LFS_FILESIZE);
 }
 
 /* llite/xattr.c */
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 5400cbe..25a06f8 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -785,7 +785,6 @@ void ll_lli_init(struct ll_inode_info *lli)
 {
lli->lli_inode_magic = LLI_INODE_MAGIC;
lli->lli_flags = 0;
-   lli->lli_maxbytes = MAX_LFS_FILESIZE;
spin_lock_init(>lli_lock);
lli->lli_posix_acl = NULL;
/* Do not set lli_fid, it has been initialized already. */
@@ -1685,14 +1684,9 @@ int ll_update_inode(struct inode *inode, struct 
lustre_md *md)
struct ll_sb_info *sbi = ll_i2sbi(inode);
 
LASSERT((lsm != NULL) == ((body->mbo_valid & OBD_MD_FLEASIZE) != 0));
-   if (lsm) {
+   if (lsm)
cl_file_inode_init(inode, md);
 
-   lli->lli_maxbytes = lsm->lsm_maxbytes;
-   if (lli->lli_maxbytes > MAX_LFS_FILESIZE)
-   lli->lli_maxbytes = MAX_LFS_FILESIZE;
-   }
-
if (S_ISDIR(inode->i_mode)) {
int rc;
 
diff --git 

[PATCH 40/41] staging: lustre: lov: move LSM to LOV layer

2016-10-02 Thread James Simmons
From: John L. Hammond 

Move the definition of struct lov_stripe_md along with supporting
functions from obd.h to lov_internal.h. Remove the unused functions
obd_packmd() and obd_free_diskmd(). Simplify lov_obd_packmd()
according to the reduced use cases and rename it lov_packmd().

Signed-off-by: John L. Hammond 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13696
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|   77 +--
 drivers/staging/lustre/lustre/include/obd_class.h  |   38 -
 .../staging/lustre/lustre/llite/llite_internal.h   |2 -
 drivers/staging/lustre/lustre/llite/vvp_internal.h |1 -
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|  105 --
 drivers/staging/lustre/lustre/lov/lov_ea.c |4 +-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |   80 +++-
 drivers/staging/lustre/lustre/lov/lov_obd.c|9 --
 drivers/staging/lustre/lustre/lov/lov_pack.c   |  145 +---
 drivers/staging/lustre/lustre/mdc/mdc_request.c|8 -
 drivers/staging/lustre/lustre/osc/osc_request.c|   63 -
 11 files changed, 118 insertions(+), 414 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index f63336f..ebb3012 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -73,53 +73,7 @@ static inline void loi_init(struct lov_oinfo *loi)
 {
 }
 
-/*
- * If we are unable to get the maximum object size from the OST in
- * ocd_maxbytes using OBD_CONNECT_MAXBYTES, then we fall back to using
- * the old maximum object size from ext3.
- */
-#define LUSTRE_EXT3_STRIPE_MAXBYTES 0x1fff000ULL
-
-struct lov_stripe_md {
-   atomic_t lsm_refc;
-   spinlock_t  lsm_lock;
-   pid_t   lsm_lock_owner; /* debugging */
-
-   /* maximum possible file size, might change as OSTs status changes,
-* e.g. disconnected, deactivated
-*/
-   loff_t  lsm_maxbytes;
-   struct ost_id   lsm_oi;
-   __u32   lsm_magic;
-   __u32   lsm_stripe_size;
-   __u32   lsm_pattern;/* striping pattern (RAID0, RAID1) */
-   __u16   lsm_stripe_count;
-   __u16   lsm_layout_gen;
-   charlsm_pool_name[LOV_MAXPOOLNAME + 1];
-   struct lov_oinfo *lsm_oinfo[0];
-};
-
-static inline bool lsm_is_released(struct lov_stripe_md *lsm)
-{
-   return !!(lsm->lsm_pattern & LOV_PATTERN_F_RELEASED);
-}
-
-static inline bool lsm_has_objects(struct lov_stripe_md *lsm)
-{
-   if (!lsm)
-   return false;
-   if (lsm_is_released(lsm))
-   return false;
-   return true;
-}
-
-static inline int lov_stripe_md_size(unsigned int stripe_count)
-{
-   struct lov_stripe_md lsm;
-
-   return sizeof(lsm) + stripe_count * sizeof(lsm.lsm_oinfo[0]);
-}
-
+struct lov_stripe_md;
 struct obd_info;
 
 typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
@@ -854,8 +808,6 @@ struct obd_ops {
  struct obd_statfs *osfs, __u64 max_age, __u32 flags);
int (*statfs_async)(struct obd_export *exp, struct obd_info *oinfo,
__u64 max_age, struct ptlrpc_request_set *set);
-   int (*packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
- struct lov_stripe_md *mem_src);
int (*unpackmd)(struct obd_export *exp,
struct lov_stripe_md **mem_tgt,
struct lov_mds_md *disk_src, int disk_len);
@@ -1033,33 +985,6 @@ struct md_ops {
 */
 };
 
-struct lsm_operations {
-   void (*lsm_free)(struct lov_stripe_md *);
-   void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, u64 *,
-   u64 *);
-   void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, u64 *,
-u64 *);
-   int (*lsm_lmm_verify)(struct lov_mds_md *lmm, int lmm_bytes,
- __u16 *stripe_count);
-   int (*lsm_unpackmd)(struct lov_obd *lov, struct lov_stripe_md *lsm,
-   struct lov_mds_md *lmm);
-};
-
-extern const struct lsm_operations lsm_v1_ops;
-extern const struct lsm_operations lsm_v3_ops;
-static inline const struct lsm_operations *lsm_op_find(int magic)
-{
-   switch (magic) {
-   case LOV_MAGIC_V1:
-  return _v1_ops;
-   case LOV_MAGIC_V3:
-  return _v3_ops;
-   default:
-  CERROR("Cannot recognize lsm_magic %08x\n", magic);
-  return NULL;
-   }
-}
-
 static inline struct md_open_data *obd_mod_alloc(void)
 {
struct md_open_data *mod;
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 

[PATCH 36/41] staging: lustre: ldlm: interval tree search in ldlm_lock_match()

2016-10-02 Thread James Simmons
From: Vitaly Fertman 

replace the linear search by interval_tree one for granted list
in ldlm_lock_match()

Signed-off-by: Vitaly Fertman 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5739
Xyratex-bug-id: MRP-2089
Reviewed-on: http://review.whamcloud.com/12294
Reviewed-by: Andreas Dilger 
Reviewed-by: Jinshan Xiong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |  249 
 1 files changed, 171 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 22b4a52..f2044ec 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1043,88 +1043,173 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct 
list_head *work_list)
 }
 
 /**
- * Search for a lock with given properties in a queue.
+ * Describe the overlap between two locks.  itree_overlap_cb data.
+ */
+struct lock_match_data {
+   struct ldlm_lock*lmd_old;
+   struct ldlm_lock*lmd_lock;
+   enum ldlm_mode  *lmd_mode;
+   ldlm_policy_data_t  *lmd_policy;
+   __u64lmd_flags;
+   int  lmd_unref;
+};
+
+/**
+ * Check if the given @lock meets the criteria for a match.
+ * A reference on the lock is taken if matched.
  *
- * \retval a referenced lock or NULL.  See the flag descriptions below, in the
- * comment above ldlm_lock_match
+ * \param lock test-against this lock
+ * \param data parameters
  */
-static struct ldlm_lock *search_queue(struct list_head *queue,
- enum ldlm_mode *mode,
- ldlm_policy_data_t *policy,
- struct ldlm_lock *old_lock,
- __u64 flags, int unref)
+static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data)
 {
-   struct ldlm_lock *lock;
-   struct list_head   *tmp;
+   ldlm_policy_data_t *lpol = >l_policy_data;
+   enum ldlm_mode match;
 
-   list_for_each(tmp, queue) {
-   enum ldlm_mode match;
+   if (lock == data->lmd_old)
+   return INTERVAL_ITER_STOP;
 
-   lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+   /*
+* Check if this lock can be matched.
+* Used by LU-2919(exclusive open) for open lease lock
+*/
+   if (ldlm_is_excl(lock))
+   return INTERVAL_ITER_CONT;
 
-   if (lock == old_lock)
-   break;
+   /*
+* llite sometimes wants to match locks that will be
+* canceled when their users drop, but we allow it to match
+* if it passes in CBPENDING and the lock still has users.
+* this is generally only going to be used by children
+* whose parents already hold a lock so forward progress
+* can still happen.
+*/
+   if (ldlm_is_cbpending(lock) &&
+   !(data->lmd_flags & LDLM_FL_CBPENDING))
+   return INTERVAL_ITER_CONT;
 
-   /* Check if this lock can be matched.
-* Used by LU-2919(exclusive open) for open lease lock
-*/
-   if (ldlm_is_excl(lock))
-   continue;
+   if (!data->lmd_unref && ldlm_is_cbpending(lock) &&
+   !lock->l_readers && !lock->l_writers)
+   return INTERVAL_ITER_CONT;
 
-   /* llite sometimes wants to match locks that will be
-* canceled when their users drop, but we allow it to match
-* if it passes in CBPENDING and the lock still has users.
-* this is generally only going to be used by children
-* whose parents already hold a lock so forward progress
-* can still happen.
-*/
-   if (ldlm_is_cbpending(lock) && !(flags & LDLM_FL_CBPENDING))
-   continue;
-   if (!unref && ldlm_is_cbpending(lock) &&
-   lock->l_readers == 0 && lock->l_writers == 0)
-   continue;
+   if (!(lock->l_req_mode & *data->lmd_mode))
+   return INTERVAL_ITER_CONT;
+   match = lock->l_req_mode;
 
-   if (!(lock->l_req_mode & *mode))
-   continue;
-   match = lock->l_req_mode;
-
-   if (lock->l_resource->lr_type == LDLM_EXTENT &&
-   (lock->l_policy_data.l_extent.start >
-policy->l_extent.start ||
-lock->l_policy_data.l_extent.end < policy->l_extent.end))
-   continue;
+   switch (lock->l_resource->lr_type) {
+   case LDLM_EXTENT:
+   if (lpol->l_extent.start > data->lmd_policy->l_extent.start ||
+   lpol->l_extent.end < data->lmd_policy->l_extent.end)
+  

[PATCH 23/41] staging: lustre: mgc: MGC should retry for invalid import

2016-10-02 Thread James Simmons
From: wang di 

After http://review.whamcloud.com/#/c/9967/ is landed, mgc does
not wait the import connected(state = FULL), then enqueue and
retrieve config log, which will cause the mount process to fail,
especially if the mgc is shared by multiple targets.
So once mgc enqueue is failed, it will give another chance to
wait the import to recover, if the import comes back in time,
it will try to enqueue again. Otherwise it will use local config log.

Signed-off-by: wang di 
Signed-off-by: Andreas Dilger 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5420
Reviewed-on: http://review.whamcloud.com/11258
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/lustre_ha.h |1 +
 drivers/staging/lustre/lustre/mgc/mgc_request.c   |   85 +++--
 drivers/staging/lustre/lustre/ptlrpc/import.c |3 +-
 3 files changed, 81 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_ha.h 
b/drivers/staging/lustre/lustre/include/lustre_ha.h
index cde7ed7..dec1e99 100644
--- a/drivers/staging/lustre/lustre/include/lustre_ha.h
+++ b/drivers/staging/lustre/lustre/include/lustre_ha.h
@@ -53,6 +53,7 @@ void ptlrpc_activate_import(struct obd_import *imp);
 void ptlrpc_deactivate_import(struct obd_import *imp);
 void ptlrpc_invalidate_import(struct obd_import *imp);
 void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt);
+void ptlrpc_pinger_force(struct obd_import *imp);
 
 /** @} ha */
 
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c 
b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 1a0e59a..7b5ac44 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1552,14 +1552,52 @@ out_free:
return rc;
 }
 
-/** Get a config log from the MGS and process it.
- * This func is called for both clients and servers.
- * Copy the log locally before parsing it if appropriate (non-MGS server)
+static bool mgc_import_in_recovery(struct obd_import *imp)
+{
+   bool in_recovery = true;
+
+   spin_lock(>imp_lock);
+   if (imp->imp_state == LUSTRE_IMP_FULL ||
+   imp->imp_state == LUSTRE_IMP_CLOSED)
+   in_recovery = false;
+   spin_unlock(>imp_lock);
+
+   return in_recovery;
+}
+
+/**
+ * Get a configuration log from the MGS and process it.
+ *
+ * This function is called for both clients and servers to process the
+ * configuration log from the MGS.  The MGC enqueues a DLM lock on the
+ * log from the MGS, and if the lock gets revoked the MGC will be notified
+ * by the lock cancellation callback that the config log has changed,
+ * and will enqueue another MGS lock on it, and then continue processing
+ * the new additions to the end of the log.
+ *
+ * Since the MGC import is not replayable, if the import is being evicted
+ * (rcl == -ESHUTDOWN, \see ptlrpc_import_delay_req()), retry to process
+ * the log until recovery is finished or the import is closed.
+ *
+ * Make a local copy of the log before parsing it if appropriate (non-MGS
+ * server) so that the server can start even when the MGS is down.
+ *
+ * There shouldn't be multiple processes running process_log at once --
+ * sounds like badness.  It actually might be fine, as long as they're not
+ * trying to update from the same log simultaneously, in which case we
+ * should use a per-log semaphore instead of cld_lock.
+ *
+ * \param[in] mgc  MGC device by which to fetch the configuration log
+ * \param[in] cld  log processing state (stored in lock callback data)
+ *
+ * \retval 0 on success
+ * \retval negative errno on failure
  */
 int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld)
 {
struct lustre_handle lockh = { 0 };
__u64 flags = LDLM_FL_NO_LRU;
+   bool retry = false;
int rc = 0, rcl;
 
LASSERT(cld);
@@ -1569,6 +1607,7 @@ int mgc_process_log(struct obd_device *mgc, struct 
config_llog_data *cld)
 * we're not trying to update from the same log
 * simultaneously (in which case we should use a per-log sem.)
 */
+restart:
mutex_lock(>cld_lock);
if (cld->cld_stopping) {
mutex_unlock(>cld_lock);
@@ -1592,10 +1631,42 @@ int mgc_process_log(struct obd_device *mgc, struct 
config_llog_data *cld)
} else {
CDEBUG(D_MGC, "Can't get cfg lock: %d\n", rcl);
 
-   /* mark cld_lostlock so that it will requeue
-* after MGC becomes available.
-*/
-   cld->cld_lostlock = 1;
+   if (rcl == -ESHUTDOWN &&
+   atomic_read(>u.cli.cl_mgc_refcount) > 0 && !retry) {
+   int secs = cfs_time_seconds(obd_timeout);
+   struct obd_import *imp;
+   struct l_wait_info lwi;
+
+   mutex_unlock(>cld_lock);
+   imp = 

[PATCH 32/41] staging: lustre: llite: restart short read/write for normal IO

2016-10-02 Thread James Simmons
From: Bobi Jam 

If normal IO got short read/write, we'd restart the IO from where
we've accomplished until we meet EOF or error happens.

Signed-off-by: Bobi Jam 
Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6389
Reviewed-on: http://review.whamcloud.com/14123
Reviewed-by: Andreas Dilger 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lnet/libcfs/fail.c  |1 +
 .../staging/lustre/lustre/include/obd_support.h|2 +
 drivers/staging/lustre/lustre/llite/file.c |   41 
 drivers/staging/lustre/lustre/llite/vvp_io.c   |   19 -
 4 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/fail.c 
b/drivers/staging/lustre/lnet/libcfs/fail.c
index e4b1a0a..3a9c8dd 100644
--- a/drivers/staging/lustre/lnet/libcfs/fail.c
+++ b/drivers/staging/lustre/lnet/libcfs/fail.c
@@ -113,6 +113,7 @@ int __cfs_fail_check_set(__u32 id, __u32 value, int set)
break;
case CFS_FAIL_LOC_RESET:
cfs_fail_loc = value;
+   atomic_set(_fail_count, 0);
break;
default:
LASSERTF(0, "called with bad set %u\n", set);
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h 
b/drivers/staging/lustre/lustre/include/obd_support.h
index 1233c34..7f3f8cd 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -458,6 +458,8 @@ extern char obd_jobid_var[];
 #define OBD_FAIL_LOV_INIT  0x1403
 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
 #define OBD_FAIL_LLITE_XATTR_ENOMEM0x1405
+#define OBD_FAIL_MAKE_LOVEA_HOLE   0x1406
+#define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
 #define OBD_FAIL_GETATTR_DELAY 0x1409
 
 #define OBD_FAIL_FID_INDIR 0x1501
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 94caf4f..9bf50bf 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -972,9 +972,11 @@ ll_file_io_generic(const struct lu_env *env, struct 
vvp_io_args *args,
 {
struct ll_inode_info *lli = ll_i2info(file_inode(file));
struct ll_file_data  *fd  = LUSTRE_FPRIVATE(file);
+   struct vvp_io *vio = vvp_env_io(env);
struct range_lock range;
struct cl_io *io;
-   ssize_tresult;
+   ssize_t result = 0;
+   int rc = 0;
 
CDEBUG(D_VFSTRACE, "file: %s, type: %d ppos: %llu, count: %zu\n",
   file->f_path.dentry->d_name.name, iot, *ppos, count);
@@ -1010,9 +1012,8 @@ restart:
CDEBUG(D_VFSTRACE, "Range lock [%llu, %llu]\n",
   range.rl_node.in_extent.start,
   range.rl_node.in_extent.end);
-   result = range_lock(>lli_write_tree,
-   );
-   if (result < 0)
+   rc = range_lock(>lli_write_tree, );
+   if (rc < 0)
goto out;
 
range_locked = true;
@@ -1028,7 +1029,7 @@ restart:
LBUG();
}
ll_cl_add(file, env, io);
-   result = cl_io_loop(env, io);
+   rc = cl_io_loop(env, io);
ll_cl_remove(file, env);
if (args->via_io_subtype == IO_NORMAL)
up_read(>lli_trunc_sem);
@@ -1040,24 +1041,26 @@ restart:
}
} else {
/* cl_io_rw_init() handled IO */
-   result = io->ci_result;
+   rc = io->ci_result;
}
 
if (io->ci_nob > 0) {
result = io->ci_nob;
+   count -= io->ci_nob;
*ppos = io->u.ci_wr.wr.crw_pos;
+
+   /* prepare IO restart */
+   if (count > 0 && args->via_io_subtype == IO_NORMAL)
+   args->u.normal.via_iter = vio->vui_iter;
}
-   goto out;
 out:
cl_io_fini(env, io);
-   /* If any bit been read/written (result != 0), we just return
-* short read/write instead of restart io.
-*/
-   if ((result == 0 || result == -ENODATA) && io->ci_need_restart) {
-   CDEBUG(D_VFSTRACE, "Restart %s on %pD from %lld, count:%zu\n",
+
+   if ((!rc || rc == -ENODATA) && count > 0 && io->ci_need_restart) {
+   CDEBUG(D_VFSTRACE, "%s: restart %s from %lld, count:%zu, 
result: %zd\n",
+  file_dentry(file)->d_name.name,
   iot == CIT_READ ? "read" : "write",
-  file, *ppos, count);
-   LASSERTF(io->ci_nob == 0, 

[PATCH 28/41] staging: lustre: hsm: make HSM modification requests replayable

2016-10-02 Thread James Simmons
From: Mikhail Pershin 

There are several HSM requests which modify data on server and
reply on Lustre recovery, e.g. they should replay changes in
case of recovery.

Patch allows such requests to be replayed in recovery time and
they are issued from client using mdc_rpc_lock to serialize them
and avoid concurrent last_rcvd update on server.

Signed-off-by: Mikhail Pershin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5939
Reviewed-on: http://review.whamcloud.com/13684
Reviewed-by: Jinshan Xiong 
Reviewed-by: Faccini Bruno 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/mdc/mdc_request.c |   12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 7b9fb90..1d1eaa5 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1505,7 +1505,9 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
 
ptlrpc_request_set_replen(req);
 
-   rc = mdc_queue_wait(req);
+   mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+   rc = ptlrpc_queue_wait(req);
+   mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
 out:
ptlrpc_req_finished(req);
return rc;
@@ -1683,7 +1685,9 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
 
ptlrpc_request_set_replen(req);
 
-   rc = mdc_queue_wait(req);
+   mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+   rc = ptlrpc_queue_wait(req);
+   mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
 out:
ptlrpc_req_finished(req);
return rc;
@@ -1746,7 +1750,9 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 
ptlrpc_request_set_replen(req);
 
-   rc = mdc_queue_wait(req);
+   mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+   rc = ptlrpc_queue_wait(req);
+   mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
 out:
ptlrpc_req_finished(req);
return rc;
-- 
1.7.1



Re: [LKP] [lkp] [sctp] a6c2f79287: netperf.Throughput_Mbps -37.2% regression

2016-10-02 Thread Xin Long
On Fri, Sep 30, 2016 at 3:05 PM, Aaron Lu  wrote:
> On 08/23/2016 05:44 AM, Marcelo Ricardo Leitner wrote:
>> Em 19-08-2016 04:24, Aaron Lu escreveu:
>>> On Fri, Aug 19, 2016 at 04:19:39AM -0300, Marcelo Ricardo Leitner wrote:
 Hi,

 Em 19-08-2016 02:29, Aaron Lu escreveu:
 ...
> It doesn't look insane and sctp_wait_for_sndbuf may actually have
> something to do with a larger sctp_chunk I suppose?
>
> The same perf record doesn't capture any sample for the good commit,
> which suggests the nerperf process doesn't sleep in sctp_wait_for_sndbuf.

 Ahhh yes! It does, and then it would mean your txbuf is too small for the
 chunk sizes you're using (sctp tests option -m).

 What's your netperf cmdline again please?
>>>
>>> netperf -4 -t SCTP_STREAM_MANY -c -C -l 300 -- -m 10K -H 127.0.0.1
>>>
>>> Is the 10K used here a problem? If so, can you suggest a proper value
>>> for our netperf performance test? Thanks.
>>
>> We're still working on this. Xin could reproduce it on an i3 too, but
>> I'm afraid this commit just unmasked an issue in there. You're
>> overloading the CPU by too much when spawning 8 parallel netperf's on a
>> 4-core system, seems that commit a6c2f79287 was that last rock that made
>> it slip into a precipice. sctp's cwnd and rwnd management are not as
>> good as tcp's and now it seems you're triggering a corner case.
>>
>> I hope to have more soon.
>
> I wonder if there is any update on this issue?
>
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

be4947b sctp: change to check peer prsctp_capable when using prsctp polices
0605483 sctp: remove prsctp_param from sctp_chunk
73dca12 sctp: move sent_count to the memory hole in sctp_chunk

These three commit can avoid this issue by recovering sctp_chunk size.


[PATCH 41/41] staging: lustre: echo: request pages in batches

2016-10-02 Thread James Simmons
From: Alex Zhuravlev 

rather than fetch them one by one.

Signed-off-by: Alex Zhuravlev 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5278
Reviewed-on: http://review.whamcloud.com/13612
Reviewed-by: Nathaniel Clark 
Reviewed-by: Andreas Dilger 
Signed-off-by: James Simmons 
---
 .../staging/lustre/lustre/obdecho/echo_client.c|   38 ---
 1 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c 
b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index d8e3e96..c69588c 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -1335,7 +1335,7 @@ static int echo_client_prep_commit(const struct lu_env 
*env,
 {
struct obd_ioobj ioo;
struct niobuf_local *lnb;
-   struct niobuf_remote *rnb;
+   struct niobuf_remote rnb;
u64 off;
u64 npages, tot_pages;
int i, ret = 0, brw_flags = 0;
@@ -1347,9 +1347,7 @@ static int echo_client_prep_commit(const struct lu_env 
*env,
tot_pages = count >> PAGE_SHIFT;
 
lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS);
-   rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS);
-
-   if (!lnb || !rnb) {
+   if (!lnb) {
ret = -ENOMEM;
goto out;
}
@@ -1361,25 +1359,22 @@ static int echo_client_prep_commit(const struct lu_env 
*env,
 
off = offset;
 
-   for (; tot_pages; tot_pages -= npages) {
+   for (; tot_pages > 0; tot_pages -= npages) {
int lpages;
 
if (tot_pages < npages)
npages = tot_pages;
 
-   for (i = 0; i < npages; i++, off += PAGE_SIZE) {
-   rnb[i].rnb_offset = off;
-   rnb[i].rnb_len = PAGE_SIZE;
-   rnb[i].rnb_flags = brw_flags;
-   }
-
-   ioo.ioo_bufcnt = npages;
+   rnb.rnb_offset = off;
+   rnb.rnb_len = npages * PAGE_SIZE;
+   rnb.rnb_flags = brw_flags;
+   ioo.ioo_bufcnt = 1;
+   off += npages * PAGE_SIZE;
 
lpages = npages;
-   ret = obd_preprw(env, rw, exp, oa, 1, , rnb, , lnb);
+   ret = obd_preprw(env, rw, exp, oa, 1, , , , lnb);
if (ret != 0)
goto out;
-   LASSERT(lpages == npages);
 
for (i = 0; i < lpages; i++) {
struct page *page = lnb[i].lnb_page;
@@ -1398,17 +1393,17 @@ static int echo_client_prep_commit(const struct lu_env 
*env,
 
if (rw == OBD_BRW_WRITE)
echo_client_page_debug_setup(page, rw,
-   ostid_id(>o_oi),
-rnb[i].rnb_offset,
-rnb[i].rnb_len);
+
ostid_id(>o_oi),
+
lnb[i].lnb_file_offset,
+lnb[i].lnb_len);
else
echo_client_page_debug_check(page,
-   ostid_id(>o_oi),
-rnb[i].rnb_offset,
-rnb[i].rnb_len);
+
ostid_id(>o_oi),
+
lnb[i].lnb_file_offset,
+lnb[i].lnb_len);
}
 
-   ret = obd_commitrw(env, rw, exp, oa, 1, , rnb, npages, lnb,
+   ret = obd_commitrw(env, rw, exp, oa, 1, , , npages, lnb,
   ret);
if (ret != 0)
goto out;
@@ -1420,7 +1415,6 @@ static int echo_client_prep_commit(const struct lu_env 
*env,
 
 out:
kfree(lnb);
-   kfree(rnb);
return ret;
 }
 
-- 
1.7.1



  1   2   3   4   >