Linux filesystem development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: cem@kernel.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [bug report] shmem: quota support
Date: Wed, 2 Aug 2023 09:53:54 +0300	[thread overview]
Message-ID: <ffd7ca34-7f2a-44ee-b05d-b54d920ce076@moroto.mountain> (raw)

Hello Carlos Maiolino,

The patch 9a9f8f590f6d: "shmem: quota support" from Jul 25, 2023
(linux-next), leads to the following Smatch static checker warning:

	fs/quota/dquot.c:1271 flush_warnings()
	warn: sleeping in atomic context

fs/quota/dquot.c
    1261 static void flush_warnings(struct dquot_warn *warn)
    1262 {
    1263         int i;
    1264 
    1265         for (i = 0; i < MAXQUOTAS; i++) {
    1266                 if (warn[i].w_type == QUOTA_NL_NOWARN)
    1267                         continue;
    1268 #ifdef CONFIG_PRINT_QUOTA_WARNING
    1269                 print_warning(&warn[i]);
    1270 #endif
--> 1271                 quota_send_warning(warn[i].w_dq_id,
    1272                                    warn[i].w_sb->s_dev, warn[i].w_type);

The quota_send_warning() function does GFP_NOFS allocations, which don't
touch the fs but can still sleep.  GFP_ATOMIC or GFP_NOWAIT don't sleep.

    1273         }
    1274 }

The call trees that Smatch is worried about are listed.  The "disables
preempt" functions take the spin_lock_irq(&info->lock) before calling
shmem_recalc_inode().

shmem_charge() <- disables preempt
shmem_uncharge() <- disables preempt
shmem_undo_range() <- disables preempt
shmem_getattr() <- disables preempt
shmem_writepage() <- disables preempt
shmem_set_folio_swapin_error() <- disables preempt
shmem_swapin_folio() <- disables preempt
shmem_get_folio_gfp() <- disables preempt
-> shmem_recalc_inode()
   -> shmem_inode_unacct_blocks()
      -> dquot_free_block_nodirty()
         -> dquot_free_space_nodirty()
            -> __dquot_free_space()
               -> flush_warnings()

regards,
dan carpenter

             reply	other threads:[~2023-08-02  7:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <kU3N4tqbYA3gHO6AXf5TbwIkfbkKFI9NaCK_39Uj4qC6YJKXa_j98uqXcegkmzc8Nxj8L3rD_UWv_x6y0RGv1Q==@protonmail.internalid>
2023-08-02  6:53 ` Dan Carpenter [this message]
2023-08-02 14:22   ` [bug report] shmem: quota support Carlos Maiolino
2023-08-03  0:00     ` Hugh Dickins
2023-08-03 11:10       ` Jan Kara
2023-08-03 16:53         ` Hugh Dickins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ffd7ca34-7f2a-44ee-b05d-b54d920ce076@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=cem@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox