Whamcloud - gitweb
LU-18875 quota: change lqe only under lock 12/58612/2
authorSergey Cheremencev <scherementsev@ddn.com>
Fri, 21 Mar 2025 06:32:31 +0000 (09:32 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 25 Apr 2025 00:56:39 +0000 (00:56 +0000)
commit3eca1e2d8d09652b968428e780766d61d0435926
tree1a66fb19d54af0ca7351fa103db27f79b3a0de35
parent9b4d348e7c2cb180af7e56f892bbb97bb3776414
LU-18875 quota: change lqe only under lock

All fields of an lqe, especially flags, must be changed only under a
lock protection. The flags like lqe_gl, lqe_is_reset, lqe_edquot are
the part of an unsigned long(8 bytes) memory region in lquota_entry.
It is impossible to change only 1 bit in a memory, so the general way
is to "mov" 1 byte to some register(AL), change it(AND, OR) in this
register and "mov" back to the memory. It is a window for a race and
might cause a corruption of the neighbour flags. So this patch adds a
locking for remain places where the flags or any lqe members are
changed without locking. One of known issues this patch is aimed to
sort out is the following assertion:

 (qmt_lock.c:973:qmt_id_lock_glimpse()) ASSERTION( lqe->lqe_gl )

Restore one old assertion in qmt_id_lock_glimpse that was removed by
mistake in 16ee9ecdb0 - qmt_reba_thread() is the only thread that can
change lqe_gl flag. Also check that lqe_gl is  not set when we are
freeing an lqe.

Fixes: 16ee9ecdb0 ("LU-16913 quota: fix ASSERTION(lqe->lqe_gl)")
Fixes: 78be823f33 ("LU-15218 quota: delete unused quota ID")
Signed-off-by: Sergey Cheremencev <scherementsev@ddn.com>
Change-Id: I954ed8aa23be01846e479a64c376c4b37af05268
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58612
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/quota/lquota_internal.h
lustre/quota/lquota_lib.c
lustre/quota/qmt_handler.c
lustre/quota/qmt_lock.c
lustre/quota/qsd_entry.c
lustre/quota/qsd_writeback.c