OSDN Git Service

btrfs: use GFP_KERNEL in btrfs_defrag_file
authorDavid Sterba <dsterba@suse.com>
Thu, 22 Jun 2017 01:13:02 +0000 (03:13 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 16 Aug 2017 14:12:03 +0000 (16:12 +0200)
We can safely use GFP_KERNEL, the function is called from two contexts:

- ioctl handler, called directly, no locks taken
- cleaner thread, running all queued defrag work, outside of any locks

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c

index 3e744dd..4d1b07b 100644 (file)
@@ -1277,7 +1277,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
         * context
         */
        if (!file) {
-               ra = kzalloc(sizeof(*ra), GFP_NOFS);
+               ra = kzalloc(sizeof(*ra), GFP_KERNEL);
                if (!ra)
                        return -ENOMEM;
                file_ra_state_init(ra, inode->i_mapping);
@@ -1285,8 +1285,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
                ra = &file->f_ra;
        }
 
-       pages = kmalloc_array(max_cluster, sizeof(struct page *),
-                       GFP_NOFS);
+       pages = kmalloc_array(max_cluster, sizeof(struct page *), GFP_KERNEL);
        if (!pages) {
                ret = -ENOMEM;
                goto out_ra;