[PATCH] smb: client: change allocation requirements in DUP_CTX_STR macro

Fredric Cover posted 1 patch 4 weeks, 1 day ago
fs/smb/client/fs_context.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] smb: client: change allocation requirements in DUP_CTX_STR macro
Posted by Fredric Cover 4 weeks, 1 day ago
From: Fredric Cover <fredric.cover.lkernel@gmail.com>

Currently, the macro DUP_CTX_STR allocates new_ctx->field using
GFP_ATOMIC. DUP_CTX_STR is only used in smb3_fs_context_dup(), which
is never called in an atomic context. Using GFP_ATOMIC puts unnecessary
pressure on emergency memory pools.

Change GFP_ATOMIC to GFP_KERNEL.

Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
---
 fs/smb/client/fs_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index b9544eb03..a3ccc06c0 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -420,7 +420,7 @@ static int parse_symlink_flavor(struct fs_context *fc, char *value,
 #define DUP_CTX_STR(field)						\
 do {									\
 	if (ctx->field) {						\
-		new_ctx->field = kstrdup(ctx->field, GFP_ATOMIC);	\
+		new_ctx->field = kstrdup(ctx->field, GFP_KERNEL);	\
 		if (new_ctx->field == NULL) {				\
 			smb3_cleanup_fs_context_contents(new_ctx);	\
 			return -ENOMEM;					\
-- 
2.53.0
Re: [PATCH] smb: client: change allocation requirements in DUP_CTX_STR macro
Posted by Fredric Cover 3 weeks, 2 days ago
Hi Steve,

Following up on this patch. This logic should remain sound and still
merge properly.
Let me know if you need any modifications.

Thanks,
Fredric Cover

On Wed, May 13, 2026 at 1:20 PM Fredric Cover
<fredric.cover.lkernel@gmail.com> wrote:
>
> From: Fredric Cover <fredric.cover.lkernel@gmail.com>
>
> Currently, the macro DUP_CTX_STR allocates new_ctx->field using
> GFP_ATOMIC. DUP_CTX_STR is only used in smb3_fs_context_dup(), which
> is never called in an atomic context. Using GFP_ATOMIC puts unnecessary
> pressure on emergency memory pools.
>
> Change GFP_ATOMIC to GFP_KERNEL.
>
> Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
> ---
>  fs/smb/client/fs_context.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index b9544eb03..a3ccc06c0 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -420,7 +420,7 @@ static int parse_symlink_flavor(struct fs_context *fc, char *value,
>  #define DUP_CTX_STR(field)                                             \
>  do {                                                                   \
>         if (ctx->field) {                                               \
> -               new_ctx->field = kstrdup(ctx->field, GFP_ATOMIC);       \
> +               new_ctx->field = kstrdup(ctx->field, GFP_KERNEL);       \
>                 if (new_ctx->field == NULL) {                           \
>                         smb3_cleanup_fs_context_contents(new_ctx);      \
>                         return -ENOMEM;                                 \
> --
> 2.53.0
>
Re: [PATCH] smb: client: change allocation requirements in DUP_CTX_STR macro
Posted by Steve French 3 weeks, 1 day ago
merged into cifs-2.6.git for-next pending additional testing and review

On Tue, May 19, 2026 at 8:53 PM Fredric Cover
<fredric.cover.lkernel@gmail.com> wrote:
>
> Hi Steve,
>
> Following up on this patch. This logic should remain sound and still
> merge properly.
> Let me know if you need any modifications.
>
> Thanks,
> Fredric Cover
>
> On Wed, May 13, 2026 at 1:20 PM Fredric Cover
> <fredric.cover.lkernel@gmail.com> wrote:
> >
> > From: Fredric Cover <fredric.cover.lkernel@gmail.com>
> >
> > Currently, the macro DUP_CTX_STR allocates new_ctx->field using
> > GFP_ATOMIC. DUP_CTX_STR is only used in smb3_fs_context_dup(), which
> > is never called in an atomic context. Using GFP_ATOMIC puts unnecessary
> > pressure on emergency memory pools.
> >
> > Change GFP_ATOMIC to GFP_KERNEL.
> >
> > Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
> > ---
> >  fs/smb/client/fs_context.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> > index b9544eb03..a3ccc06c0 100644
> > --- a/fs/smb/client/fs_context.c
> > +++ b/fs/smb/client/fs_context.c
> > @@ -420,7 +420,7 @@ static int parse_symlink_flavor(struct fs_context *fc, char *value,
> >  #define DUP_CTX_STR(field)                                             \
> >  do {                                                                   \
> >         if (ctx->field) {                                               \
> > -               new_ctx->field = kstrdup(ctx->field, GFP_ATOMIC);       \
> > +               new_ctx->field = kstrdup(ctx->field, GFP_KERNEL);       \
> >                 if (new_ctx->field == NULL) {                           \
> >                         smb3_cleanup_fs_context_contents(new_ctx);      \
> >                         return -ENOMEM;                                 \
> > --
> > 2.53.0
> >
>


-- 
Thanks,

Steve