Re: GFS

From: Pekka J Enberg
Date: Mon Aug 08 2005 - 09:15:10 EST


David Teigland writes:
+static ssize_t walk_vm_hard(struct file *file, char *buf, size_t size,
+ loff_t *offset, do_rw_t operation)
+{
+ struct gfs2_holder *ghs;
+ unsigned int num_gh = 0;
+ ssize_t count;
+
+ {

Can we please get rid of the extra braces everywhere?

[snip]

David Teigland writes:
+
+ for (vma = find_vma(mm, start); vma; vma = vma->vm_next) {
+ if (end <= vma->vm_start)
+ break;
+ if (vma->vm_file &&
+ vma->vm_file->f_dentry->d_inode->i_sb == sb) {
+ num_gh++;
+ }
+ }
+
+ ghs = kmalloc((num_gh + 1) * sizeof(struct gfs2_holder),
+ GFP_KERNEL);
+ if (!ghs) {
+ if (!dumping)
+ up_read(&mm->mmap_sem);
+ return -ENOMEM;
+ }
+
+ for (vma = find_vma(mm, start); vma; vma = vma->vm_next) {

Sorry if this is an obvious question but what prevents another thread from doing mmap() before we do the second walk and messing up num_gh?

+ if (end <= vma->vm_start)
+ break;
+ if (vma->vm_file) {
+ struct inode *inode;
+ inode = vma->vm_file->f_dentry->d_inode;
+ if (inode->i_sb == sb)
+ gfs2_holder_init(get_v2ip(inode)->i_gl,
+ vma2state(vma),
+ 0, &ghs[x++]);
+ }
+ }

Pekka

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/