When the CONFIG_DEBUG_SG flag is enabled in the kernel, we must ensure
the sg_magic field is properly initialized. Otherwise, internal kernel
assertions will fail when trying to verify this field. As a result,
certain calls to sg_* function had to be changed or inserted to ensure
the sg_init_table function would be called, initializing the magic
value. Also, we need to ensure this value isn't zeroed out in the
kiblnd_setup_rd_kiov function.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Alexander Boyko <alexander_boyko@xyratex.com>
Reviewed-by: Alexander Zarochentsev <alexander_zarochentsev@xyratex.com>
Reviewed-by: Andrew Perepechko <andrew_perepechko@xyratex.com>
Change-Id: I5b6b265a4a8dd37408bb78decd79ed54e0f9251b
Reviewed-on: http://review.whamcloud.com/3709
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
+# 2.6.24-rc1 sg_init_table
+AC_DEFUN([LIBCFS_SCATTERLIST_INITTABLE],
+[AC_MSG_CHECKING([for sg_init_table])
+LB_LINUX_TRY_COMPILE([
+ #include <asm/types.h>
+ #include <linux/scatterlist.h>
+],[
+ sg_init_table(NULL,0);
+],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SCATTERLIST_INITTABLE, 1,
+ [scatterlist has sg_init_table])
+],[
+ AC_MSG_RESULT(NO)
+])
+])
+
+# 2.6.24
AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
[AC_MSG_CHECKING([for network stack has namespaces])
LB_LINUX_TRY_COMPILE([
AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
[AC_MSG_CHECKING([for network stack has namespaces])
LB_LINUX_TRY_COMPILE([
# 2.6.24
LIBCFS_SYSCTL_UNNUMBERED
LIBCFS_SCATTERLIST_SETPAGE
# 2.6.24
LIBCFS_SYSCTL_UNNUMBERED
LIBCFS_SCATTERLIST_SETPAGE
+LIBCFS_SCATTERLIST_INITTABLE
LIBCFS_NETWORK_NAMESPACE
LIBCFS_FUNC_DUMP_TRACE
# 2.6.26
LIBCFS_NETWORK_NAMESPACE
LIBCFS_FUNC_DUMP_TRACE
# 2.6.26
#endif /* HAVE_STRUCT_CRED */
#endif /* HAVE_STRUCT_CRED */
+#ifndef HAVE_SCATTERLIST_INITTABLE
+#define sg_init_table(sg, nents) memset(sg, 0, sizeof(*(sg))*(nents))
+#endif
+
+#ifndef HAVE_SCATTERLIST_SETPAGE
+#define sg_set_page(sg, p, len, off) \
+ sg_set_buf(sg, page_address(p) + ((off) & ~CFS_PAGE_MASK), len)
+#endif
+
#endif /* _LINUX_LIBCFS_H */
#endif /* _LINUX_LIBCFS_H */
unsigned char *key, unsigned int key_len,
unsigned char *hash, unsigned int *hash_len)
{
unsigned char *key, unsigned int key_len,
unsigned char *hash, unsigned int *hash_len)
{
- struct scatterlist sl = {0};
struct hash_desc hdesc;
int err;
const struct cfs_crypto_hash_type *type;
struct hash_desc hdesc;
int err;
const struct cfs_crypto_hash_type *type;
crypto_free_hash(hdesc.tfm);
return -ENOSPC;
}
crypto_free_hash(hdesc.tfm);
return -ENOSPC;
}
- sg_set_buf(&sl, (void *)buf, buf_len);
+ sg_init_one(&sl, (void *)buf, buf_len);
hdesc.flags = 0;
err = crypto_hash_digest(&hdesc, &sl, sl.length, hash);
hdesc.flags = 0;
err = crypto_hash_digest(&hdesc, &sl, sl.length, hash);
cfs_page_t *page, unsigned int offset,
unsigned int len)
{
cfs_page_t *page, unsigned int offset,
unsigned int len)
{
- struct scatterlist sl = {0};
sg_set_page(&sl, page, len, offset & ~CFS_PAGE_MASK);
return crypto_hash_update((struct hash_desc *)hdesc, &sl, sl.length);
sg_set_page(&sl, page, len, offset & ~CFS_PAGE_MASK);
return crypto_hash_update((struct hash_desc *)hdesc, &sl, sl.length);
int cfs_crypto_hash_update(struct cfs_crypto_hash_desc *hdesc,
const void *buf, unsigned int buf_len)
{
int cfs_crypto_hash_update(struct cfs_crypto_hash_desc *hdesc,
const void *buf, unsigned int buf_len)
{
- struct scatterlist sl = {0};
- sg_set_buf(&sl, (void *)buf, buf_len);
+ sg_init_one(&sl, (void *)buf, buf_len);
return crypto_hash_update((struct hash_desc *)hdesc, &sl, sl.length);
}
return crypto_hash_update((struct hash_desc *)hdesc, &sl, sl.length);
}
if (tx->tx_frags == NULL)
break;
if (tx->tx_frags == NULL)
break;
+ sg_init_table(tx->tx_frags, IBLND_MAX_RDMA_FRAGS);
+
LIBCFS_CPT_ALLOC(tx->tx_wrq, lnet_cpt_table(), ps->ps_cpt,
(1 + IBLND_MAX_RDMA_FRAGS) *
sizeof(*tx->tx_wrq));
LIBCFS_CPT_ALLOC(tx->tx_wrq, lnet_cpt_table(), ps->ps_cpt,
(1 + IBLND_MAX_RDMA_FRAGS) *
sizeof(*tx->tx_wrq));
fragnob = min((int)(kiov->kiov_len - offset), nob);
fragnob = min((int)(kiov->kiov_len - offset), nob);
- memset(sg, 0, sizeof(*sg));
sg_set_page(sg, kiov->kiov_page, fragnob,
kiov->kiov_offset + offset);
sg++;
sg_set_page(sg, kiov->kiov_page, fragnob,
kiov->kiov_offset + offset);
sg++;