lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20060830165924.2955d8d1.akpm@osdl.org>
Date:	Wed, 30 Aug 2006 16:59:24 -0700
From:	Andrew Morton <akpm@...l.org>
To:	"Gorka Guardiola" <paurealkml@...il.com>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: Buffer head async write

On Wed, 30 Aug 2006 11:35:44 -0500
"Gorka Guardiola" <paurealkml@...il.com> wrote:

> I am trying to 	mark a buffer for async write, but I am  having a race condition
> to unlock the buffer. I am doing.
> 
>         bh = getbmapst(bdev, nsect); //this function calls bread
> 	if (!bh) {
> 		printk(KERN_ALERT "I/O error, bitmap cannot be trusted\n");
> 		return -1;
> 	}
> 	
> 	lock_buffer(bh);	
> 
> 	byte = bh->b_data + byteoffset;
> 	*byte |= 1 << bitoffset;
> 	lock_page(bh->b_page);
> 	mark_page_accessed(bh->b_page);
> 	__set_page_dirty_nobuffers(bh->b_page);
> 	unlock_page(bh->b_page);
> 	set_buffer_uptodate(bh);
> 	mark_buffer_dirty(bh);
> 	mark_buffer_async_write(bh);
> 	unlock_buffer(bh);
> 	brelse(bh);

There are rather a lot of mistakes in there.

More like this:

	lock_page(bh->b_page);
	lock_buffer(bh);
	byte = bh->b_data + byteoffset;
	*byte |= 1 << bitoffset;
	mark_buffer_dirty(bh);
	unlock_buffer(bh);
	flush_dcache_page(page);
	unlock_page(page);
	put_bh(bh);

now, the buffer is dirty and will be written back by pdflush, sync, etc.

If you really want to start async IO against that buffer now, do

	ll_rw_block(WRITE, 1, &bh);

just before the final put_bh().

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ