Skip to contentSkip to conversation

ocfs2/dlmfs: use GFP_KERNEL instead of GFP_NOFS

PATCH New Wengang Wang 3 participants 4 messages Nov 16, 2010 – Nov 17, 2010 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2/dlmfs: use GFP_KERNEL instead of GFP_NOFS

There is no need for dlmfs to sync data to disk so that no memory is needed for that purpose. So no worry about the live lock: sync data -> alloc mem -> sync data ->.... We'd better use GFP_KERNEL instead of GFP_NOFS to allow FS sync during the memory allocation.

---
 fs/ocfs2/dlmfs/dlmfs.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +4 -4
index b2df490..979b593 100644
@@ -151,7 +151,7 @@ static int dlmfs_file_open(struct inode *inode,
 	 * doesn't make sense for LVB writes. */
 	file->f_flags &= ~O_APPEND;
 
-	fp = kmalloc(sizeof(*fp), GFP_NOFS);
+	fp = kmalloc(sizeof(*fp), GFP_KERNEL);
 	if (!fp) {
 		status = -ENOMEM;
 		goto bail;
@@ -265,7 +265,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
 	else
 		readlen = count;
 
-	lvb_buf = kmalloc(readlen, GFP_NOFS);
+	lvb_buf = kmalloc(readlen, GFP_KERNEL);
 	if (!lvb_buf)
 		return -ENOMEM;
 
@@ -313,7 +313,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
 	else
 		writelen = count - *ppos;
 
-	lvb_buf = kmalloc(writelen, GFP_NOFS);
+	lvb_buf = kmalloc(writelen, GFP_KERNEL);
 	if (!lvb_buf)
 		return -ENOMEM;
 
@@ -344,7 +344,7 @@ static struct inode *dlmfs_alloc_inode(struct super_block *sb)
 {
 	struct dlmfs_inode_private *ip;
 
-	ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_NOFS);
+	ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_KERNEL);
 	if (!ip)
 		return NULL;
 
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/1 ocfs2/dlmfs: use GFP_KERNEL instead of GFP_NOFS

We do NOFS allocs in the dlm to prevent deadlocks (not live locks). And you are right we don't have to do NOFS allocs here. But the sizes we are talking about are really small. Do we really care?

Quoted 50 lines · Wengang Wang

There is no need for dlmfs to sync data to disk so that no memory is needed for that purpose. So no worry about the live lock: sync data -> alloc mem -> sync data ->.... We'd better use GFP_KERNEL instead of GFP_NOFS to allow FS sync during the memory allocation.

---
  fs/ocfs2/dlmfs/dlmfs.c |    8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +4 -4
index b2df490..979b593 100644
@@ -151,7 +151,7 @@ static int dlmfs_file_open(struct inode *inode,
  	 * doesn't make sense for LVB writes. */
  	file->f_flags&= ~O_APPEND;
 
-	fp = kmalloc(sizeof(*fp), GFP_NOFS);
+	fp = kmalloc(sizeof(*fp), GFP_KERNEL);
  	if (!fp) {
  		status = -ENOMEM;
  		goto bail;
@@ -265,7 +265,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
  	else
  		readlen = count;
 
-	lvb_buf = kmalloc(readlen, GFP_NOFS);
+	lvb_buf = kmalloc(readlen, GFP_KERNEL);
  	if (!lvb_buf)
  		return -ENOMEM;
 
@@ -313,7 +313,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
  	else
  		writelen = count - *ppos;
 
-	lvb_buf = kmalloc(writelen, GFP_NOFS);
+	lvb_buf = kmalloc(writelen, GFP_KERNEL);
  	if (!lvb_buf)
  		return -ENOMEM;
 
@@ -344,7 +344,7 @@ static struct inode *dlmfs_alloc_inode(struct super_block *sb)
  {
  	struct dlmfs_inode_private *ip;
 
-	ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_NOFS);
+	ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_KERNEL);
  	if (!ip)
  		return NULL;
 
#2 lore raw

PATCH 1/1 ocfs2/dlmfs: use GFP_KERNEL instead of GFP_NOFS

Quoted 3 lines · Sunil Mushran

We do NOFS allocs in the dlm to prevent deadlocks (not live locks). And you are right we don't have to do NOFS allocs here. But the sizes we are talking about are really small. Do we really care?

I didn't hit problem at the allocation with NOFS. I just noticed it when looking at the codes. Since the sizes are small, it shouldn't effects much.

The locks I meant is not dlm related. It's when system feel memory pressure and causes filesystems sync data to disk to free memory. During that time I think it's live lock if we allocate memory(GFP_KERNEL) when syncing data to disk. no?

regards,
wengang.

Quoted 7 lines · Wengang Wang
Quoted 5 lines

There is no need for dlmfs to sync data to disk so that no memory is needed for that purpose. So no worry about the live lock: sync data -> alloc mem -> sync data ->.... We'd better use GFP_KERNEL instead of GFP_NOFS to allow FS sync during the memory allocation.

#3 lore raw

PATCH 1/1 ocfs2/dlmfs: use GFP_KERNEL instead of GFP_NOFS

Quoted 8 lines · Wengang Wang
Quoted 3 lines · Sunil Mushran

We do NOFS allocs in the dlm to prevent deadlocks (not live locks). And you are right we don't have to do NOFS allocs here. But the sizes we are talking about are really small. Do we really care?

I didn't hit problem at the allocation with NOFS. I just noticed it when looking at the codes. Since the sizes are small, it shouldn't effects much.

I'm going to vote -EDONTCARE.

Joel

Signature · 8 lines
"Friends may come and go, but enemies accumulate." 
        - Thomas Jones

Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127