Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1628724 > unrolled thread

[PATCH] fs/ocfs2/cluster: use offset_in_page() macro

Started byGeliang Tang <geliangtang@gmail.com>
First post2017-04-22 03:30 +0200
Last post2017-04-24 09:20 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] fs/ocfs2/cluster: use offset_in_page() macro Geliang Tang <geliangtang@gmail.com> - 2017-04-22 03:30 +0200
    [PATCH] xprtrdma: use offset_in_page() macro Geliang Tang <geliangtang@gmail.com> - 2017-04-22 03:30 +0200
      Re: [PATCH] xprtrdma: use offset_in_page() macro Chuck Lever <chuck.lever@oracle.com> - 2017-04-22 05:40 +0200
    [PATCH] tty/serial: atmel: use offset_in_page() macro Geliang Tang <geliangtang@gmail.com> - 2017-04-22 03:30 +0200
      Re: [PATCH] tty/serial: atmel: use offset_in_page() macro Richard Genoud <richard.genoud@gmail.com> - 2017-04-24 09:20 +0200

#1628724 — [PATCH] fs/ocfs2/cluster: use offset_in_page() macro

FromGeliang Tang <geliangtang@gmail.com>
Date2017-04-22 03:30 +0200
Subject[PATCH] fs/ocfs2/cluster: use offset_in_page() macro
Message-ID<tyS26-4Ml-7@gated-at.bofh.it>
Use offset_in_page() macro instead of open-coding.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 fs/ocfs2/cluster/tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index a4a6ba2..8d77922 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -955,7 +955,7 @@ static void o2net_sendpage(struct o2net_sock_container *sc,
 		mutex_lock(&sc->sc_send_lock);
 		ret = sc->sc_sock->ops->sendpage(sc->sc_sock,
 						 virt_to_page(kmalloced_virt),
-						 (long)kmalloced_virt & ~PAGE_MASK,
+						 offset_in_page(kmalloced_virt),
 						 size, MSG_DONTWAIT);
 		mutex_unlock(&sc->sc_send_lock);
 		if (ret == size)
-- 
2.9.3

[toc] | [next] | [standalone]


#1628725 — [PATCH] xprtrdma: use offset_in_page() macro

FromGeliang Tang <geliangtang@gmail.com>
Date2017-04-22 03:30 +0200
Subject[PATCH] xprtrdma: use offset_in_page() macro
Message-ID<tyS27-4Ml-31@gated-at.bofh.it>
In reply to#1628724
Use offset_in_page() macro instead of open-coding.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 net/sunrpc/xprtrdma/rpc_rdma.c        | 4 ++--
 net/sunrpc/xprtrdma/svc_rdma_sendto.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
index a044be2..429beea 100644
--- a/net/sunrpc/xprtrdma/rpc_rdma.c
+++ b/net/sunrpc/xprtrdma/rpc_rdma.c
@@ -540,7 +540,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
 			goto out;
 
 		page = virt_to_page(xdr->tail[0].iov_base);
-		page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK;
+		page_base = offset_in_page(xdr->tail[0].iov_base);
 
 		/* If the content in the page list is an odd length,
 		 * xdr_write_pages() has added a pad at the beginning
@@ -587,7 +587,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
 	 */
 	if (xdr->tail[0].iov_len) {
 		page = virt_to_page(xdr->tail[0].iov_base);
-		page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK;
+		page_base = offset_in_page(xdr->tail[0].iov_base);
 		len = xdr->tail[0].iov_len;
 
 map_tail:
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
index 1736337..60b3f29 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
@@ -306,12 +306,11 @@ static int svc_rdma_dma_map_buf(struct svcxprt_rdma *rdma,
 				unsigned char *base,
 				unsigned int len)
 {
-	unsigned long offset = (unsigned long)base & ~PAGE_MASK;
 	struct ib_device *dev = rdma->sc_cm_id->device;
 	dma_addr_t dma_addr;
 
 	dma_addr = ib_dma_map_page(dev, virt_to_page(base),
-				   offset, len, DMA_TO_DEVICE);
+				   offset_in_page(base), len, DMA_TO_DEVICE);
 	if (ib_dma_mapping_error(dev, dma_addr))
 		return -EIO;
 
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1628768 — Re: [PATCH] xprtrdma: use offset_in_page() macro

FromChuck Lever <chuck.lever@oracle.com>
Date2017-04-22 05:40 +0200
SubjectRe: [PATCH] xprtrdma: use offset_in_page() macro
Message-ID<tyU3T-61v-23@gated-at.bofh.it>
In reply to#1628725
> On Apr 21, 2017, at 9:21 PM, Geliang Tang <geliangtang@gmail.com> wrote:
> 
> Use offset_in_page() macro instead of open-coding.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
> net/sunrpc/xprtrdma/rpc_rdma.c        | 4 ++--
> net/sunrpc/xprtrdma/svc_rdma_sendto.c | 3 +--
> 2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
> index a044be2..429beea 100644
> --- a/net/sunrpc/xprtrdma/rpc_rdma.c
> +++ b/net/sunrpc/xprtrdma/rpc_rdma.c
> @@ -540,7 +540,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
> 			goto out;
> 
> 		page = virt_to_page(xdr->tail[0].iov_base);
> -		page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK;
> +		page_base = offset_in_page(xdr->tail[0].iov_base);
> 
> 		/* If the content in the page list is an odd length,
> 		 * xdr_write_pages() has added a pad at the beginning
> @@ -587,7 +587,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
> 	 */
> 	if (xdr->tail[0].iov_len) {
> 		page = virt_to_page(xdr->tail[0].iov_base);
> -		page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK;
> +		page_base = offset_in_page(xdr->tail[0].iov_base);
> 		len = xdr->tail[0].iov_len;
> 
> map_tail:

There are several other sites that use PAGE_MASK in
rpc_rdma.c. Should those be included in this patch?

Do you have a way to test this change? If not I
can take it (once the above comment is addressed),
run it through the usual battery of NFS/RDMA
testing, and then pass it along to Anna.


> diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> index 1736337..60b3f29 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> @@ -306,12 +306,11 @@ static int svc_rdma_dma_map_buf(struct svcxprt_rdma *rdma,
> 				unsigned char *base,
> 				unsigned int len)
> {
> -	unsigned long offset = (unsigned long)base & ~PAGE_MASK;
> 	struct ib_device *dev = rdma->sc_cm_id->device;
> 	dma_addr_t dma_addr;
> 
> 	dma_addr = ib_dma_map_page(dev, virt_to_page(base),
> -				   offset, len, DMA_TO_DEVICE);
> +				   offset_in_page(base), len, DMA_TO_DEVICE);
> 	if (ib_dma_mapping_error(dev, dma_addr))
> 		return -EIO;
> 

This hunk conflicts with a rewrite of svc_rdma_sendto.c that
Bruce has already accepted for v4.12. I would prefer this
be dropped.

The rewritten code also has this issue. I can submit a patch
separately that adds offset_in_page in the appropriate place.


--
Chuck Lever

[toc] | [prev] | [next] | [standalone]


#1628727 — [PATCH] tty/serial: atmel: use offset_in_page() macro

FromGeliang Tang <geliangtang@gmail.com>
Date2017-04-22 03:30 +0200
Subject[PATCH] tty/serial: atmel: use offset_in_page() macro
Message-ID<tyS27-4Ml-29@gated-at.bofh.it>
In reply to#1628724
Use offset_in_page() macro instead of open-coding.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/tty/serial/atmel_serial.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index c355ac9..f398db8 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -959,7 +959,7 @@ static int atmel_prepare_tx_dma(struct uart_port *port)
 	sg_set_page(&atmel_port->sg_tx,
 			virt_to_page(port->state->xmit.buf),
 			UART_XMIT_SIZE,
-			(unsigned long)port->state->xmit.buf & ~PAGE_MASK);
+			offset_in_page(port->state->xmit.buf));
 	nent = dma_map_sg(port->dev,
 				&atmel_port->sg_tx,
 				1,
@@ -1141,7 +1141,7 @@ static int atmel_prepare_rx_dma(struct uart_port *port)
 	sg_set_page(&atmel_port->sg_rx,
 		    virt_to_page(ring->buf),
 		    sizeof(struct atmel_uart_char) * ATMEL_SERIAL_RINGSIZE,
-		    (unsigned long)ring->buf & ~PAGE_MASK);
+		    offset_in_page(ring->buf));
 	nent = dma_map_sg(port->dev,
 			  &atmel_port->sg_rx,
 			  1,
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1629262 — Re: [PATCH] tty/serial: atmel: use offset_in_page() macro

FromRichard Genoud <richard.genoud@gmail.com>
Date2017-04-24 09:20 +0200
SubjectRe: [PATCH] tty/serial: atmel: use offset_in_page() macro
Message-ID<tzGrU-3YY-25@gated-at.bofh.it>
In reply to#1628727
On 22/04/2017 03:21, Geliang Tang wrote:
> Use offset_in_page() macro instead of open-coding.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
>  drivers/tty/serial/atmel_serial.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index c355ac9..f398db8 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -959,7 +959,7 @@ static int atmel_prepare_tx_dma(struct uart_port *port)
>  	sg_set_page(&atmel_port->sg_tx,
>  			virt_to_page(port->state->xmit.buf),
>  			UART_XMIT_SIZE,
> -			(unsigned long)port->state->xmit.buf & ~PAGE_MASK);
> +			offset_in_page(port->state->xmit.buf));
>  	nent = dma_map_sg(port->dev,
>  				&atmel_port->sg_tx,
>  				1,
> @@ -1141,7 +1141,7 @@ static int atmel_prepare_rx_dma(struct uart_port *port)
>  	sg_set_page(&atmel_port->sg_rx,
>  		    virt_to_page(ring->buf),
>  		    sizeof(struct atmel_uart_char) * ATMEL_SERIAL_RINGSIZE,
> -		    (unsigned long)ring->buf & ~PAGE_MASK);
> +		    offset_in_page(ring->buf));
>  	nent = dma_map_sg(port->dev,
>  			  &atmel_port->sg_rx,
>  			  1,
> 
I guess you want to #include <linux/mm.h>
(even if it compiles ok without it)

Regards,
Richard.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web