public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h]
@ 2013-05-17  5:39 Jeff Liu
  2013-05-17  7:51 ` Michael L. Semon
  2013-05-17  8:36 ` Michael L. Semon
  0 siblings, 2 replies; 7+ messages in thread
From: Jeff Liu @ 2013-05-17  5:39 UTC (permalink / raw)
  To: xfs@oss.sgi.com

From: Jie Liu <jeff.liu@oracle.com>

Add source files for xfs_log_rlimit.[c|h].
The new source would be used for the log space validation.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>

---
 fs/xfs/Makefile         |    3 +-
 fs/xfs/xfs_log_rlimit.c |  148 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/xfs/xfs_log_rlimit.h |   25 ++++++++
 fs/xfs/xfs_mount.h      |    3 +
 4 files changed, 178 insertions(+), 1 deletion(-)
 create mode 100644 fs/xfs/xfs_log_rlimit.c
 create mode 100644 fs/xfs/xfs_log_rlimit.h

diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 6313b69..7e7a49d 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -75,7 +75,8 @@ xfs-y				+= xfs_alloc.o \
 				   xfs_log_recover.o \
 				   xfs_mount.o \
 				   xfs_symlink.o \
-				   xfs_trans.o
+				   xfs_trans.o \
+				   xfs_log_rlimit.o
 
 # low-level transaction/log code
 xfs-y				+= xfs_log.o \
diff --git a/fs/xfs/xfs_log_rlimit.c b/fs/xfs/xfs_log_rlimit.c
new file mode 100644
index 0000000..3e84d46
--- /dev/null
+++ b/fs/xfs/xfs_log_rlimit.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2013 Jie Liu.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+#include "xfs.h"
+#include "xfs_fs.h"
+#include "xfs_sb.h"
+#include "xfs_mount.h"
+#include "xfs_trans_space.h"
+#include "xfs_bmap_btree.h"
+#include "xfs_inode.h"
+#include "xfs_log.h"
+#include "xfs_log_priv.h"
+#include "xfs_da_btree.h"
+#include "xfs_attr_leaf.h"
+
+void
+xfs_log_adjust_max_attrsetm_res(
+	struct xfs_mount	*mp)
+{
+	int			size;
+	int			nblks;
+	int			res;
+
+	/*
+	 * Calculate the maximum length in bytes that would be required
+	 * for a local attribute value as large attributes out of line
+	 * are not logged.
+	 */
+	size = xfs_attr_leaf_entsize_local_max(mp->m_sb.sb_blocksize) -
+	       MAXNAMELEN - 1;
+	nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
+	nblks += XFS_B_TO_FSB(mp, size);
+	nblks += XFS_NEXTENTADD_SPACE_RES(mp, size, XFS_ATTR_FORK);
+
+	res = m_tresp(mp)->tr_attrsetm.tr_logres +
+	      m_tresp(mp)->tr_attrsetrt.tr_logres * nblks;
+	mp->m_reservations.tr_attrsetm.tr_logres = res;
+}
+
+/*
+ * Iterate over the log space reservation table to figure out and return
+ * the maximum one in terms of the pre-calculated values which were done
+ * at mount time.
+ */
+void
+xfs_log_get_max_trans_res(
+	struct xfs_mount		*mp,
+	struct xfs_trans_res		*max_tresp)
+{
+	struct xfs_trans_reservations	*mtresp = m_tresp(mp);
+	struct xfs_trans_res		tres_items[XFS_TRANS_RES_NUM];
+	struct xfs_trans_res		*tresp;
+	int				i, logspace  = 0;
+
+	xfs_log_adjust_max_attrsetm_res(mp);
+
+	memcpy(tres_items, mtresp, sizeof(*mtresp));
+	for (i = 0; i < ARRAY_SIZE(tres_items); i++) {
+		struct xfs_trans_res	*p = &tres_items[i];
+		int			tmp = p->tr_logcount > 1 ?
+					      p->tr_logres * p->tr_logcount :
+					      p->tr_logres;
+		if (logspace < tmp) {
+			logspace = tmp;
+			tresp = p;
+		}
+	}
+
+	*max_tresp = *tresp;
+}
+
+/*
+ * Verify if the configured log space is sufficient or not for the specified
+ * log stripe unit.
+ */
+void
+xfs_log_validate_logspace(
+	struct xfs_mount	*mp)
+{
+	struct xlog		*log = mp->m_log;
+	struct xfs_trans_res	tres;
+	int			maxlres;
+	int			minlblks = 0, lsunit = 0;
+
+	xfs_log_get_max_trans_res(mp, &tres);
+
+	maxlres = xfs_log_calc_unit_res(mp, tres.tr_logres);
+	maxlres = tres.tr_logcount > 1 ? maxlres * tres.tr_logcount : maxlres;
+
+	if (xfs_sb_version_haslogv2(&log->l_mp->m_sb) &&
+	    log->l_mp->m_sb.sb_logsunit > 1)
+		lsunit = BTOBB(log->l_mp->m_sb.sb_logsunit);
+
+	/*
+	 * Two factors should be taken into account for calculating the minimum
+	 * log space.
+	 * 1) The fundamental limitation is that no single transaction can be
+	 *    larger than half size of the log.
+	 * 2) If the lsunit option is specified, a transaction requires 2 LSU
+	 *    for the reservation because there are two log writes that can
+	 *    require padding - the transaction data and the commit record which
+	 *    are written separately and both can require padding to the LSU.
+	 *    Consider that we can have an active CIL reservation holding 2*LSU,
+	 *    but the CIL is not over a push threshold, in this case, if we
+	 *    don't have enough log space for at one new transaction, which
+	 *    includes another 2*LSU in the reservation, we will run into dead
+	 *    loop situation in log space grant procedure. i.e.
+	 *    xlog_grant_head_wait().
+	 *
+	 *    Hence the log size needs to be able to contain two maximally sized
+	 *    and padded transactions, which is (2 * (2 * LSU + maxlres)).
+	 *
+	 * Also, the log size should be a multiple of the log stripe unit, round
+	 * it up to lsunit boundary if lsunit is specified.
+	 */
+	minlblks = lsunit ? (roundup(BTOBB(maxlres), lsunit) + 2 * lsunit) * 2 :
+			    BTOBB(maxlres) * 2;
+
+	if (log->l_logBBsize < minlblks) {
+		xfs_crit(mp,
+		"Log size %d blocks too small, minimu size is %d blocks",
+			 log->l_logBBsize, minlblks);
+	}
+	if (log->l_logBBsize > XFS_MAX_LOG_BLOCKS) {
+		xfs_crit(mp,
+		"Log size %d blocks too large, maximum size is %lld blocks",
+			 log->l_logBBsize, XFS_MAX_LOG_BLOCKS);
+	}
+	if (log->l_logsize > XFS_MAX_LOG_BYTES) {
+		xfs_crit(mp,
+		"log size %lld bytes too large, maximum size is %lld bytes",
+			 (long long)(log->l_logsize), XFS_MAX_LOG_BYTES);
+	}
+}
diff --git a/fs/xfs/xfs_log_rlimit.h b/fs/xfs/xfs_log_rlimit.h
new file mode 100644
index 0000000..93d8a0e
--- /dev/null
+++ b/fs/xfs/xfs_log_rlimit.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2013 Jie Liu.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+#ifndef	__XFS_LOG_RLIMIT_H__
+#define __XFS_LOG_RLIMIT_H__
+
+void xfs_log_adjust_max_attrsetm_res(struct xfs_mount *);
+void xfs_log_get_max_trans_res(struct xfs_mount *, struct xfs_trans_res *);
+void xfs_log_validate_logspace(struct xfs_mount *);
+
+#endif	/* __XFS_LOG_PRIV_H__ */
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 27ae8a9..2b469a5 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -62,6 +62,9 @@ typedef struct xfs_trans_reservations {
 	struct xfs_trans_res	tr_fsyncts;	/* update timestamps on fsync */
 } xfs_trans_reservations_t;
 
+#define XFS_TRANS_RES_NUM (sizeof(struct xfs_trans_reservations) / \
+			   sizeof(struct xfs_trans_res))
+
 #ifndef __KERNEL__
 
 #define xfs_daddr_to_agno(mp,d) \
-- 
1.7.9.5

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h]
  2013-05-17  5:39 [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h] Jeff Liu
@ 2013-05-17  7:51 ` Michael L. Semon
  2013-05-17  8:36 ` Michael L. Semon
  1 sibling, 0 replies; 7+ messages in thread
From: Michael L. Semon @ 2013-05-17  7:51 UTC (permalink / raw)
  To: Jeff Liu; +Cc: xfs@oss.sgi.com

How do I get this to build?  With gcc-4.8.0, the kernel build ends like 
this:

   LINK    vmlinux
   LD      vmlinux.o
   MODPOST vmlinux.o
   GEN     .version
   CHK     include/generated/compile.h
   UPD     include/generated/compile.h
   CC      init/version.o
   LD      init/built-in.o
fs/built-in.o: In function `xfs_log_validate_logspace':
/usr/src/kernel-git/linux/fs/xfs/xfs_log_rlimit.c:130: undefined 
reference to `__udivdi3'
make: *** [vmlinux] Error 1

The fs/xfs section of the kernel did build without errors, though.

Thanks!

Michael

On 05/17/2013 01:39 AM, Jeff Liu wrote:
> From: Jie Liu <jeff.liu@oracle.com>
>
> Add source files for xfs_log_rlimit.[c|h].
> The new source would be used for the log space validation.
>
> Signed-off-by: Jie Liu <jeff.liu@oracle.com>
>
> ---
>   fs/xfs/Makefile         |    3 +-
>   fs/xfs/xfs_log_rlimit.c |  148 +++++++++++++++++++++++++++++++++++++++++++++++
>   fs/xfs/xfs_log_rlimit.h |   25 ++++++++
>   fs/xfs/xfs_mount.h      |    3 +
>   4 files changed, 178 insertions(+), 1 deletion(-)
>   create mode 100644 fs/xfs/xfs_log_rlimit.c
>   create mode 100644 fs/xfs/xfs_log_rlimit.h
>
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index 6313b69..7e7a49d 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -75,7 +75,8 @@ xfs-y				+= xfs_alloc.o \
>   				   xfs_log_recover.o \
>   				   xfs_mount.o \
>   				   xfs_symlink.o \
> -				   xfs_trans.o
> +				   xfs_trans.o \
> +				   xfs_log_rlimit.o
>
>   # low-level transaction/log code
>   xfs-y				+= xfs_log.o \
> diff --git a/fs/xfs/xfs_log_rlimit.c b/fs/xfs/xfs_log_rlimit.c
> new file mode 100644
> index 0000000..3e84d46
> --- /dev/null
> +++ b/fs/xfs/xfs_log_rlimit.c
> @@ -0,0 +1,148 @@
> +/*
> + * Copyright (c) 2013 Jie Liu.
> + * All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it would be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write the Free Software Foundation,
> + * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + */
> +#include "xfs.h"
> +#include "xfs_fs.h"
> +#include "xfs_sb.h"
> +#include "xfs_mount.h"
> +#include "xfs_trans_space.h"
> +#include "xfs_bmap_btree.h"
> +#include "xfs_inode.h"
> +#include "xfs_log.h"
> +#include "xfs_log_priv.h"
> +#include "xfs_da_btree.h"
> +#include "xfs_attr_leaf.h"
> +
> +void
> +xfs_log_adjust_max_attrsetm_res(
> +	struct xfs_mount	*mp)
> +{
> +	int			size;
> +	int			nblks;
> +	int			res;
> +
> +	/*
> +	 * Calculate the maximum length in bytes that would be required
> +	 * for a local attribute value as large attributes out of line
> +	 * are not logged.
> +	 */
> +	size = xfs_attr_leaf_entsize_local_max(mp->m_sb.sb_blocksize) -
> +	       MAXNAMELEN - 1;
> +	nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
> +	nblks += XFS_B_TO_FSB(mp, size);
> +	nblks += XFS_NEXTENTADD_SPACE_RES(mp, size, XFS_ATTR_FORK);
> +
> +	res = m_tresp(mp)->tr_attrsetm.tr_logres +
> +	      m_tresp(mp)->tr_attrsetrt.tr_logres * nblks;
> +	mp->m_reservations.tr_attrsetm.tr_logres = res;
> +}
> +
> +/*
> + * Iterate over the log space reservation table to figure out and return
> + * the maximum one in terms of the pre-calculated values which were done
> + * at mount time.
> + */
> +void
> +xfs_log_get_max_trans_res(
> +	struct xfs_mount		*mp,
> +	struct xfs_trans_res		*max_tresp)
> +{
> +	struct xfs_trans_reservations	*mtresp = m_tresp(mp);
> +	struct xfs_trans_res		tres_items[XFS_TRANS_RES_NUM];
> +	struct xfs_trans_res		*tresp;
> +	int				i, logspace  = 0;
> +
> +	xfs_log_adjust_max_attrsetm_res(mp);
> +
> +	memcpy(tres_items, mtresp, sizeof(*mtresp));
> +	for (i = 0; i < ARRAY_SIZE(tres_items); i++) {
> +		struct xfs_trans_res	*p = &tres_items[i];
> +		int			tmp = p->tr_logcount > 1 ?
> +					      p->tr_logres * p->tr_logcount :
> +					      p->tr_logres;
> +		if (logspace < tmp) {
> +			logspace = tmp;
> +			tresp = p;
> +		}
> +	}
> +
> +	*max_tresp = *tresp;
> +}
> +
> +/*
> + * Verify if the configured log space is sufficient or not for the specified
> + * log stripe unit.
> + */
> +void
> +xfs_log_validate_logspace(
> +	struct xfs_mount	*mp)
> +{
> +	struct xlog		*log = mp->m_log;
> +	struct xfs_trans_res	tres;
> +	int			maxlres;
> +	int			minlblks = 0, lsunit = 0;
> +
> +	xfs_log_get_max_trans_res(mp, &tres);
> +
> +	maxlres = xfs_log_calc_unit_res(mp, tres.tr_logres);
> +	maxlres = tres.tr_logcount > 1 ? maxlres * tres.tr_logcount : maxlres;
> +
> +	if (xfs_sb_version_haslogv2(&log->l_mp->m_sb) &&
> +	    log->l_mp->m_sb.sb_logsunit > 1)
> +		lsunit = BTOBB(log->l_mp->m_sb.sb_logsunit);
> +
> +	/*
> +	 * Two factors should be taken into account for calculating the minimum
> +	 * log space.
> +	 * 1) The fundamental limitation is that no single transaction can be
> +	 *    larger than half size of the log.
> +	 * 2) If the lsunit option is specified, a transaction requires 2 LSU
> +	 *    for the reservation because there are two log writes that can
> +	 *    require padding - the transaction data and the commit record which
> +	 *    are written separately and both can require padding to the LSU.
> +	 *    Consider that we can have an active CIL reservation holding 2*LSU,
> +	 *    but the CIL is not over a push threshold, in this case, if we
> +	 *    don't have enough log space for at one new transaction, which
> +	 *    includes another 2*LSU in the reservation, we will run into dead
> +	 *    loop situation in log space grant procedure. i.e.
> +	 *    xlog_grant_head_wait().
> +	 *
> +	 *    Hence the log size needs to be able to contain two maximally sized
> +	 *    and padded transactions, which is (2 * (2 * LSU + maxlres)).
> +	 *
> +	 * Also, the log size should be a multiple of the log stripe unit, round
> +	 * it up to lsunit boundary if lsunit is specified.
> +	 */
> +	minlblks = lsunit ? (roundup(BTOBB(maxlres), lsunit) + 2 * lsunit) * 2 :
> +			    BTOBB(maxlres) * 2;
> +
> +	if (log->l_logBBsize < minlblks) {
> +		xfs_crit(mp,
> +		"Log size %d blocks too small, minimu size is %d blocks",
> +			 log->l_logBBsize, minlblks);
> +	}
> +	if (log->l_logBBsize > XFS_MAX_LOG_BLOCKS) {
> +		xfs_crit(mp,
> +		"Log size %d blocks too large, maximum size is %lld blocks",
> +			 log->l_logBBsize, XFS_MAX_LOG_BLOCKS);
> +	}
> +	if (log->l_logsize > XFS_MAX_LOG_BYTES) {
> +		xfs_crit(mp,
> +		"log size %lld bytes too large, maximum size is %lld bytes",
> +			 (long long)(log->l_logsize), XFS_MAX_LOG_BYTES);
> +	}
> +}
> diff --git a/fs/xfs/xfs_log_rlimit.h b/fs/xfs/xfs_log_rlimit.h
> new file mode 100644
> index 0000000..93d8a0e
> --- /dev/null
> +++ b/fs/xfs/xfs_log_rlimit.h
> @@ -0,0 +1,25 @@
> +/*
> + * Copyright (c) 2013 Jie Liu.
> + * All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it would be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write the Free Software Foundation,
> + * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + */
> +#ifndef	__XFS_LOG_RLIMIT_H__
> +#define __XFS_LOG_RLIMIT_H__
> +
> +void xfs_log_adjust_max_attrsetm_res(struct xfs_mount *);
> +void xfs_log_get_max_trans_res(struct xfs_mount *, struct xfs_trans_res *);
> +void xfs_log_validate_logspace(struct xfs_mount *);
> +
> +#endif	/* __XFS_LOG_PRIV_H__ */
> diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
> index 27ae8a9..2b469a5 100644
> --- a/fs/xfs/xfs_mount.h
> +++ b/fs/xfs/xfs_mount.h
> @@ -62,6 +62,9 @@ typedef struct xfs_trans_reservations {
>   	struct xfs_trans_res	tr_fsyncts;	/* update timestamps on fsync */
>   } xfs_trans_reservations_t;
>
> +#define XFS_TRANS_RES_NUM (sizeof(struct xfs_trans_reservations) / \
> +			   sizeof(struct xfs_trans_res))
> +
>   #ifndef __KERNEL__
>
>   #define xfs_daddr_to_agno(mp,d) \
>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h]
  2013-05-17  5:39 [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h] Jeff Liu
  2013-05-17  7:51 ` Michael L. Semon
@ 2013-05-17  8:36 ` Michael L. Semon
  2013-05-17  9:40   ` Jeff Liu
  1 sibling, 1 reply; 7+ messages in thread
From: Michael L. Semon @ 2013-05-17  8:36 UTC (permalink / raw)
  To: Jeff Liu; +Cc: xfs@oss.sgi.com

On 05/17/2013 01:39 AM, Jeff Liu wrote:
> From: Jie Liu <jeff.liu@oracle.com>
>
> Add source files for xfs_log_rlimit.[c|h].
> The new source would be used for the log space validation.

Update:  To build the kernel, I'm getting by on a sysadmin hack that 
looks like this:

--- linux/fs/xfs/xfs_log_rlimit.c.orig	2013-05-17 03:36:28.983493357 -0400
+++ linux/fs/xfs/xfs_log_rlimit.c	2013-05-17 04:21:07.090661828 -0400
@@ -127,8 +127,10 @@
  	 * Also, the log size should be a multiple of the log stripe unit, round
  	 * it up to lsunit boundary if lsunit is specified.
  	 */
-	minlblks = lsunit ? (roundup(BTOBB(maxlres), lsunit) + 2 * lsunit) * 2 :
-			    BTOBB(maxlres) * 2;
+	minlblks = lsunit ?
+		(roundup((const int)(BTOBB(maxlres)), lsunit) +
+		2 * lsunit) * 2 :
+			BTOBB(maxlres) * 2;

  	if (log->l_logBBsize < minlblks) {
  		xfs_crit(mp,

However, that makes no sense.  There is a roundup in <linux/kernel.h> 
that goes like this:

/* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */
#define roundup(x, y) (                                 \
{                                                       \
         const typeof(y) __y = y;                        \
         (((x) + (__y - 1)) / __y) * __y;                \
}                                                       \
)

Okay, so that gave me the inspiration to cast the type so gcc-4.8.0 
wouldn't call __divdi3.  But why did this make a difference?

Disclaimer:  I'm not a C macro guru, so I don't know which random 
sequence of punctuation keys would make roundup() happy.

Michael

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h]
  2013-05-17  8:36 ` Michael L. Semon
@ 2013-05-17  9:40   ` Jeff Liu
  2013-05-17 10:29     ` Dave Chinner
  2013-05-17 19:31     ` Michael L. Semon
  0 siblings, 2 replies; 7+ messages in thread
From: Jeff Liu @ 2013-05-17  9:40 UTC (permalink / raw)
  To: Michael L. Semon; +Cc: xfs@oss.sgi.com

Hi Michael,

Are you compiling kernel on 32-bit system?

Looks this issue is regarding 64-bit division at roundup() on 32-bit if so.

Could you please try below fix?

diff --git a/fs/xfs/xfs_log_rlimit.c b/fs/xfs/xfs_log_rlimit.c
index 3e84d46..49a88cc 100644
--- a/fs/xfs/xfs_log_rlimit.c
+++ b/fs/xfs/xfs_log_rlimit.c
@@ -127,7 +127,7 @@ xfs_log_validate_logspace(
         * Also, the log size should be a multiple of the log stripe unit, round
         * it up to lsunit boundary if lsunit is specified.
         */
-       minlblks = lsunit ? (roundup(BTOBB(maxlres), lsunit) + 2 * lsunit) * 2 :
+       minlblks = lsunit ? (roundup((int)BTOBB(maxlres), lsunit) + 2 * lsunit) * 2 :
                            BTOBB(maxlres) * 2;
 
        if (log->l_logBBsize < minlblks) {


Thanks,
-Jeff
On 05/17/2013 04:36 PM, Michael L. Semon wrote:
> On 05/17/2013 01:39 AM, Jeff Liu wrote:
>> From: Jie Liu <jeff.liu@oracle.com>
>>
>> Add source files for xfs_log_rlimit.[c|h].
>> The new source would be used for the log space validation.
> 
> Update:  To build the kernel, I'm getting by on a sysadmin hack that 
> looks like this:
> 
> --- linux/fs/xfs/xfs_log_rlimit.c.orig	2013-05-17 03:36:28.983493357 -0400
> +++ linux/fs/xfs/xfs_log_rlimit.c	2013-05-17 04:21:07.090661828 -0400
> @@ -127,8 +127,10 @@
>   	 * Also, the log size should be a multiple of the log stripe unit, round
>   	 * it up to lsunit boundary if lsunit is specified.
>   	 */
> -	minlblks = lsunit ? (roundup(BTOBB(maxlres), lsunit) + 2 * lsunit) * 2 :
> -			    BTOBB(maxlres) * 2;
> +	minlblks = lsunit ?
> +		(roundup((const int)(BTOBB(maxlres)), lsunit) +
> +		2 * lsunit) * 2 :
> +			BTOBB(maxlres) * 2;
> 
>   	if (log->l_logBBsize < minlblks) {
>   		xfs_crit(mp,
> 
> However, that makes no sense.  There is a roundup in <linux/kernel.h> 
> that goes like this:
> 
> /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */
> #define roundup(x, y) (                                 \
> {                                                       \
>          const typeof(y) __y = y;                        \
>          (((x) + (__y - 1)) / __y) * __y;                \
> }                                                       \
> )
> 
> Okay, so that gave me the inspiration to cast the type so gcc-4.8.0 
> wouldn't call __divdi3.  But why did this make a difference?
> 
> Disclaimer:  I'm not a C macro guru, so I don't know which random 
> sequence of punctuation keys would make roundup() happy.

> 
> Michael
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h]
  2013-05-17  9:40   ` Jeff Liu
@ 2013-05-17 10:29     ` Dave Chinner
  2013-05-17 10:34       ` Jeff Liu
  2013-05-17 19:31     ` Michael L. Semon
  1 sibling, 1 reply; 7+ messages in thread
From: Dave Chinner @ 2013-05-17 10:29 UTC (permalink / raw)
  To: Jeff Liu; +Cc: Michael L. Semon, xfs@oss.sgi.com

On Fri, May 17, 2013 at 05:40:43PM +0800, Jeff Liu wrote:
> Hi Michael,
> 
> Are you compiling kernel on 32-bit system?
> 
> Looks this issue is regarding 64-bit division at roundup() on 32-bit if so.

roundup_64() is what you want, then.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h]
  2013-05-17 10:29     ` Dave Chinner
@ 2013-05-17 10:34       ` Jeff Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff Liu @ 2013-05-17 10:34 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Michael L. Semon, xfs@oss.sgi.com

On 05/17/2013 06:29 PM, Dave Chinner wrote:
> On Fri, May 17, 2013 at 05:40:43PM +0800, Jeff Liu wrote:
>> Hi Michael,
>>
>> Are you compiling kernel on 32-bit system?
>>
>> Looks this issue is regarding 64-bit division at roundup() on 32-bit if so.
> 
> roundup_64() is what you want, then.
Yep, will take care of it.

Thanks,
-Jeff

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h]
  2013-05-17  9:40   ` Jeff Liu
  2013-05-17 10:29     ` Dave Chinner
@ 2013-05-17 19:31     ` Michael L. Semon
  1 sibling, 0 replies; 7+ messages in thread
From: Michael L. Semon @ 2013-05-17 19:31 UTC (permalink / raw)
  To: Jeff Liu; +Cc: xfs@oss.sgi.com

On 05/17/2013 05:40 AM, Jeff Liu wrote:
> Hi Michael,
>
> Are you compiling kernel on 32-bit system?

Yes, this is a 32-bit Pentium 4 system.

> Looks this issue is regarding 64-bit division at roundup() on 32-bit if so.
>
> Could you please try below fix?
>
> diff --git a/fs/xfs/xfs_log_rlimit.c b/fs/xfs/xfs_log_rlimit.c
> index 3e84d46..49a88cc 100644
> --- a/fs/xfs/xfs_log_rlimit.c
> +++ b/fs/xfs/xfs_log_rlimit.c
> @@ -127,7 +127,7 @@ xfs_log_validate_logspace(
>           * Also, the log size should be a multiple of the log stripe unit, round
>           * it up to lsunit boundary if lsunit is specified.
>           */
> -       minlblks = lsunit ? (roundup(BTOBB(maxlres), lsunit) + 2 * lsunit) * 2 :
> +       minlblks = lsunit ? (roundup((int)BTOBB(maxlres), lsunit) + 2 * lsunit) * 2 :
>                              BTOBB(maxlres) * 2;
>
>          if (log->l_logBBsize < minlblks) {
>
>
> Thanks,
> -Jeff

This code works, and my sysadmin-hack use of "const" was not needed 
after all.  If you use Dave's suggestion to use roundup_64(), I'll be 
happy to apply another patch.

Thanks!

Michael

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-05-17 19:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-17  5:39 [PATCH v2 7/8] xfs: Add xfs_log_rlimit.[c|h] Jeff Liu
2013-05-17  7:51 ` Michael L. Semon
2013-05-17  8:36 ` Michael L. Semon
2013-05-17  9:40   ` Jeff Liu
2013-05-17 10:29     ` Dave Chinner
2013-05-17 10:34       ` Jeff Liu
2013-05-17 19:31     ` Michael L. Semon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox