[pacman-dev] [PATCH] libalpm: sync changes to disc when appropriate

Thomas Bächler thomas at archlinux.org
Sat Mar 14 08:40:54 EDT 2009


Dan McGee schrieb:
> We don't make calls to fsync() or fdatasync() when we are attempting to do
> something transactionally, such as writing out one of our DB entries. Add a
> call to fdatasync() when we write DB entries, and also ensure we sync our
> log changes to disc whenever we close it.
> 
> Another important thing to ensure is that we commit removals of DB entries.
> The method isn't necessarily pretty, but it works in _alpm_db_remove().

Can we get this in the maint branch as well? I had this several times 
yesterday when experimenting with 2.6.29-rc8 and some experimental intel 
driver stuff and it crashed a lot. I eventually had to disable delalloc 
on my / to make this go away.

> @@ -881,6 +880,15 @@ int _alpm_db_remove(pmdb_t *db, pmpkg_t *info)
>  
>  	ret = _alpm_rmrf(pkgpath);
>  	free(pkgpath);
> +	/* by syncing the parent directory, we can be sure the removal is
> +	 * committed to disk. */
> +	fd = open(db->path, 0);
> +	if(fd != -1) {
> +		fsync(fd);
> +		close(fd);
> +	} else {
> +		ret = -1;
> +	}
>  	if(ret != 0) {
>  		ret = -1;
>  	}

If I understood it correctly, we also have to sync the parent directory 
when adding new files, not only when removing. Not entirely sure though.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://www.archlinux.org/pipermail/pacman-dev/attachments/20090314/b6640aa8/attachment.pgp>


More information about the pacman-dev mailing list