add patch add-nombcache-mount-option
[ext4-patch-queue.git] / add-ext4_is_quota_file
blob83db0fb23ec14b8c237a9ab89c409407a11bc82f
1 ext4: add ext4_is_quota_file()
3 From: Tahsin Erdogan <tahsin@google.com>
5 IS_NOQUOTA() indicates whether quota is disabled for an inode. Ext4
6 also uses it to check whether an inode is for a quota file. The
7 distinction currently doesn't matter because quota is disabled only
8 for the quota files. When we start disabling quota for other inodes
9 in the future, we will want to make the distinction clear.
11 Replace IS_NOQUOTA() call with ext4_is_quota_file() at places where
12 we are checking for quota files.
14 Signed-off-by: Tahsin Erdogan <tahsin@google.com>
15 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
16 ---
17  fs/ext4/ext4.h        | 2 ++
18  fs/ext4/inode.c       | 2 +-
19  fs/ext4/ioctl.c       | 4 ++--
20  fs/ext4/mballoc.c     | 2 +-
21  fs/ext4/move_extent.c | 2 +-
22  5 files changed, 7 insertions(+), 5 deletions(-)
24 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
25 index e4a75c643731..3b02bd897b61 100644
26 --- a/fs/ext4/ext4.h
27 +++ b/fs/ext4/ext4.h
28 @@ -2099,6 +2099,8 @@ static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
29         return (struct ext4_inode *) (iloc->bh->b_data + iloc->offset);
30  }
32 +#define ext4_is_quota_file(inode) IS_NOQUOTA(inode)
34  /*
35   * This structure is stuffed into the struct file's private_data field
36   * for directories.  It is where we put information so that we can do
37 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
38 index 8ee20b586567..cf91532765a4 100644
39 --- a/fs/ext4/inode.c
40 +++ b/fs/ext4/inode.c
41 @@ -739,7 +739,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
42                 if (map->m_flags & EXT4_MAP_NEW &&
43                     !(map->m_flags & EXT4_MAP_UNWRITTEN) &&
44                     !(flags & EXT4_GET_BLOCKS_ZERO) &&
45 -                   !IS_NOQUOTA(inode) &&
46 +                   !ext4_is_quota_file(inode) &&
47                     ext4_should_order_data(inode)) {
48                         if (flags & EXT4_GET_BLOCKS_IO_SUBMIT)
49                                 ret = ext4_jbd2_inode_add_wait(handle, inode);
50 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
51 index 0c21e22acd74..dde8deb11e59 100644
52 --- a/fs/ext4/ioctl.c
53 +++ b/fs/ext4/ioctl.c
54 @@ -218,7 +218,7 @@ static int ext4_ioctl_setflags(struct inode *inode,
55         unsigned int jflag;
57         /* Is it quota file? Do not allow user to mess with it */
58 -       if (IS_NOQUOTA(inode))
59 +       if (ext4_is_quota_file(inode))
60                 goto flags_out;
62         oldflags = ei->i_flags;
63 @@ -342,7 +342,7 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
64         err = -EPERM;
65         inode_lock(inode);
66         /* Is it quota file? Do not allow user to mess with it */
67 -       if (IS_NOQUOTA(inode))
68 +       if (ext4_is_quota_file(inode))
69                 goto out_unlock;
71         err = ext4_get_inode_loc(inode, &iloc);
72 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
73 index b7928cddd539..d109a2a2fea0 100644
74 --- a/fs/ext4/mballoc.c
75 +++ b/fs/ext4/mballoc.c
76 @@ -4464,7 +4464,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
77         trace_ext4_request_blocks(ar);
79         /* Allow to use superuser reservation for quota file */
80 -       if (IS_NOQUOTA(ar->inode))
81 +       if (ext4_is_quota_file(ar->inode))
82                 ar->flags |= EXT4_MB_USE_ROOT_BLOCKS;
84         if ((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0) {
85 diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
86 index c992ef2c2f94..9bb36909ec92 100644
87 --- a/fs/ext4/move_extent.c
88 +++ b/fs/ext4/move_extent.c
89 @@ -484,7 +484,7 @@ mext_check_arguments(struct inode *orig_inode,
90                 return -EBUSY;
91         }
93 -       if (IS_NOQUOTA(orig_inode) || IS_NOQUOTA(donor_inode)) {
94 +       if (ext4_is_quota_file(orig_inode) && ext4_is_quota_file(donor_inode)) {
95                 ext4_debug("ext4 move extent: The argument files should "
96                         "not be quota files [ino:orig %lu, donor %lu]\n",
97                         orig_inode->i_ino, donor_inode->i_ino);
98 -- 
99 2.13.1.611.g7e3b11ae1-goog