Commit 9544bc53 authored by Jens Axboe's avatar Jens Axboe

sg: remove ->sg_magic member

This was introduced more than a decade ago when sg chaining was
added, but we never really caught anything with it. The scatterlist
entry size can be critical, since drivers allocate it, so remove
the magic member. Recently it's been triggering allocation stalls
and failures in NVMe.
Tested-by: default avatarJordan Glover <Golden_Miller83@protonmail.ch>
Acked-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 49f1c610
...@@ -2238,9 +2238,6 @@ static inline struct scatterlist *____sg_next(struct scatterlist *sg) ...@@ -2238,9 +2238,6 @@ static inline struct scatterlist *____sg_next(struct scatterlist *sg)
**/ **/
static inline struct scatterlist *__sg_next(struct scatterlist *sg) static inline struct scatterlist *__sg_next(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
#endif
return sg_is_last(sg) ? NULL : ____sg_next(sg); return sg_is_last(sg) ? NULL : ____sg_next(sg);
} }
......
...@@ -9,9 +9,6 @@ ...@@ -9,9 +9,6 @@
#include <asm/io.h> #include <asm/io.h>
struct scatterlist { struct scatterlist {
#ifdef CONFIG_DEBUG_SG
unsigned long sg_magic;
#endif
unsigned long page_link; unsigned long page_link;
unsigned int offset; unsigned int offset;
unsigned int length; unsigned int length;
...@@ -64,7 +61,6 @@ struct sg_table { ...@@ -64,7 +61,6 @@ struct sg_table {
* *
*/ */
#define SG_MAGIC 0x87654321
#define SG_CHAIN 0x01UL #define SG_CHAIN 0x01UL
#define SG_END 0x02UL #define SG_END 0x02UL
...@@ -98,7 +94,6 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page) ...@@ -98,7 +94,6 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
*/ */
BUG_ON((unsigned long) page & (SG_CHAIN | SG_END)); BUG_ON((unsigned long) page & (SG_CHAIN | SG_END));
#ifdef CONFIG_DEBUG_SG #ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
BUG_ON(sg_is_chain(sg)); BUG_ON(sg_is_chain(sg));
#endif #endif
sg->page_link = page_link | (unsigned long) page; sg->page_link = page_link | (unsigned long) page;
...@@ -129,7 +124,6 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page, ...@@ -129,7 +124,6 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page,
static inline struct page *sg_page(struct scatterlist *sg) static inline struct page *sg_page(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG #ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
BUG_ON(sg_is_chain(sg)); BUG_ON(sg_is_chain(sg));
#endif #endif
return (struct page *)((sg)->page_link & ~(SG_CHAIN | SG_END)); return (struct page *)((sg)->page_link & ~(SG_CHAIN | SG_END));
...@@ -195,9 +189,6 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, ...@@ -195,9 +189,6 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
**/ **/
static inline void sg_mark_end(struct scatterlist *sg) static inline void sg_mark_end(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
#endif
/* /*
* Set termination bit, clear potential chain bit * Set termination bit, clear potential chain bit
*/ */
...@@ -215,9 +206,6 @@ static inline void sg_mark_end(struct scatterlist *sg) ...@@ -215,9 +206,6 @@ static inline void sg_mark_end(struct scatterlist *sg)
**/ **/
static inline void sg_unmark_end(struct scatterlist *sg) static inline void sg_unmark_end(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
#endif
sg->page_link &= ~SG_END; sg->page_link &= ~SG_END;
} }
...@@ -260,12 +248,6 @@ static inline void *sg_virt(struct scatterlist *sg) ...@@ -260,12 +248,6 @@ static inline void *sg_virt(struct scatterlist *sg)
static inline void sg_init_marker(struct scatterlist *sgl, static inline void sg_init_marker(struct scatterlist *sgl,
unsigned int nents) unsigned int nents)
{ {
#ifdef CONFIG_DEBUG_SG
unsigned int i;
for (i = 0; i < nents; i++)
sgl[i].sg_magic = SG_MAGIC;
#endif
sg_mark_end(&sgl[nents - 1]); sg_mark_end(&sgl[nents - 1]);
} }
......
...@@ -24,9 +24,6 @@ ...@@ -24,9 +24,6 @@
**/ **/
struct scatterlist *sg_next(struct scatterlist *sg) struct scatterlist *sg_next(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
#endif
if (sg_is_last(sg)) if (sg_is_last(sg))
return NULL; return NULL;
...@@ -111,10 +108,7 @@ struct scatterlist *sg_last(struct scatterlist *sgl, unsigned int nents) ...@@ -111,10 +108,7 @@ struct scatterlist *sg_last(struct scatterlist *sgl, unsigned int nents)
for_each_sg(sgl, sg, nents, i) for_each_sg(sgl, sg, nents, i)
ret = sg; ret = sg;
#ifdef CONFIG_DEBUG_SG
BUG_ON(sgl[0].sg_magic != SG_MAGIC);
BUG_ON(!sg_is_last(ret)); BUG_ON(!sg_is_last(ret));
#endif
return ret; return ret;
} }
EXPORT_SYMBOL(sg_last); EXPORT_SYMBOL(sg_last);
......
...@@ -36,7 +36,6 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page) ...@@ -36,7 +36,6 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
*/ */
BUG_ON((unsigned long) page & 0x03); BUG_ON((unsigned long) page & 0x03);
#ifdef CONFIG_DEBUG_SG #ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
BUG_ON(sg_is_chain(sg)); BUG_ON(sg_is_chain(sg));
#endif #endif
sg->page_link = page_link | (unsigned long) page; sg->page_link = page_link | (unsigned long) page;
...@@ -67,7 +66,6 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page, ...@@ -67,7 +66,6 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page,
static inline struct page *sg_page(struct scatterlist *sg) static inline struct page *sg_page(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG #ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
BUG_ON(sg_is_chain(sg)); BUG_ON(sg_is_chain(sg));
#endif #endif
return (struct page *)((sg)->page_link & ~0x3); return (struct page *)((sg)->page_link & ~0x3);
...@@ -116,9 +114,6 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, ...@@ -116,9 +114,6 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
**/ **/
static inline void sg_mark_end(struct scatterlist *sg) static inline void sg_mark_end(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
#endif
/* /*
* Set termination bit, clear potential chain bit * Set termination bit, clear potential chain bit
*/ */
...@@ -136,17 +131,11 @@ static inline void sg_mark_end(struct scatterlist *sg) ...@@ -136,17 +131,11 @@ static inline void sg_mark_end(struct scatterlist *sg)
**/ **/
static inline void sg_unmark_end(struct scatterlist *sg) static inline void sg_unmark_end(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
#endif
sg->page_link &= ~0x02; sg->page_link &= ~0x02;
} }
static inline struct scatterlist *sg_next(struct scatterlist *sg) static inline struct scatterlist *sg_next(struct scatterlist *sg)
{ {
#ifdef CONFIG_DEBUG_SG
BUG_ON(sg->sg_magic != SG_MAGIC);
#endif
if (sg_is_last(sg)) if (sg_is_last(sg))
return NULL; return NULL;
...@@ -160,13 +149,6 @@ static inline struct scatterlist *sg_next(struct scatterlist *sg) ...@@ -160,13 +149,6 @@ static inline struct scatterlist *sg_next(struct scatterlist *sg)
static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
{ {
memset(sgl, 0, sizeof(*sgl) * nents); memset(sgl, 0, sizeof(*sgl) * nents);
#ifdef CONFIG_DEBUG_SG
{
unsigned int i;
for (i = 0; i < nents; i++)
sgl[i].sg_magic = SG_MAGIC;
}
#endif
sg_mark_end(&sgl[nents - 1]); sg_mark_end(&sgl[nents - 1]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment