From ad99025a4be18c2befaae9ad49b9f27f77e8d215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 28 Aug 2006 14:43:11 +0000 Subject: [PATCH] _fat_ioctl_ should reuse the same transaction recursively git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18669 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/dos/fat.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/add-ons/kernel/file_systems/dos/fat.c b/src/add-ons/kernel/file_systems/dos/fat.c index 7fb1182f2e..47d840ac30 100644 --- a/src/add-ons/kernel/file_systems/dos/fat.c +++ b/src/add-ons/kernel/file_systems/dos/fat.c @@ -79,7 +79,7 @@ static int32 _count_free_clusters_fat32(nspace *vol) enum { _IOCTL_COUNT_FREE_, _IOCTL_GET_ENTRY_, _IOCTL_SET_ENTRY_, _IOCTL_ALLOCATE_N_ENTRIES_ }; -static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N) +static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, int32 _tid) { int32 result = 0; uint32 n = 0, first = 0, last = 0; @@ -87,7 +87,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N) uint32 sector; uint32 off, val = 0; /* quiet warning */ uint8 *block1, *block2 = NULL; /* quiet warning */ - int32 tid = -1; + int32 tid = _tid; // mark end of chain for allocations uint32 V = (action == _IOCTL_SET_ENTRY_) ? N : 0x0fffffff; @@ -124,7 +124,8 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N) if (action != _IOCTL_SET_ENTRY_ && action != _IOCTL_ALLOCATE_N_ENTRIES_) { block1 = (uint8 *)block_cache_get(vol->fBlockCache, sector); } else { - tid = cache_start_transaction(vol->fBlockCache); + if (tid == -1) + tid = cache_start_transaction(vol->fBlockCache); block1 = (uint8 *)block_cache_get_writable(vol->fBlockCache, sector, tid); } @@ -249,7 +250,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N) ASSERT(IS_DATA_CLUSTER(last)); // set last cluster to point to us - if ((result = _fat_ioctl_(vol,_IOCTL_SET_ENTRY_,last,cluster)) < 0) { + if ((result = _fat_ioctl_(vol,_IOCTL_SET_ENTRY_,last,cluster, tid)) < 0) { ASSERT(0); goto bi; } @@ -298,7 +299,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N) bi: if (block1) block_cache_put(vol->fBlockCache, sector); - if (tid >= 0) + if (_tid == -1 && tid > 0) cache_end_transaction(vol->fBlockCache, tid, NULL, NULL); if (action == _IOCTL_ALLOCATE_N_ENTRIES_) { @@ -324,12 +325,12 @@ bi: int32 count_free_clusters(nspace *vol) { - return _fat_ioctl_(vol, _IOCTL_COUNT_FREE_, 0, 0); + return _fat_ioctl_(vol, _IOCTL_COUNT_FREE_, 0, 0, -1); } static int32 get_fat_entry(nspace *vol, uint32 cluster) { - int32 value = _fat_ioctl_(vol, _IOCTL_GET_ENTRY_, cluster, 0); + int32 value = _fat_ioctl_(vol, _IOCTL_GET_ENTRY_, cluster, 0, -1); if (value < 0) return value; @@ -349,7 +350,7 @@ static int32 get_fat_entry(nspace *vol, uint32 cluster) static status_t set_fat_entry(nspace *vol, uint32 cluster, int32 value) { - return _fat_ioctl_(vol, _IOCTL_SET_ENTRY_, cluster, value); + return _fat_ioctl_(vol, _IOCTL_SET_ENTRY_, cluster, value, -1); } // traverse n fat entries @@ -449,7 +450,7 @@ status_t allocate_n_fat_entries(nspace *vol, int32 n, int32 *start) DPRINTF(2, ("allocating %lx fat entries\n", n)); - c = _fat_ioctl_(vol, _IOCTL_ALLOCATE_N_ENTRIES_, 0, n); + c = _fat_ioctl_(vol, _IOCTL_ALLOCATE_N_ENTRIES_, 0, n, -1); if (c < 0) return c; @@ -669,4 +670,5 @@ status_t fragment(nspace *vol, uint32 *pattern) return B_OK; } -*/ \ No newline at end of file +*/ +