Merge with IET r196:

- Allow removal of kernel target objects if the user space object does not exist

Based on a patch by Lars Ellenberg.

Signed-off-by: Arne Redlich <agr@powerkom-dd.de>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@653 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2009-01-30 16:49:01 +00:00
parent 922c377cd2
commit ff10abd363

View File

@@ -81,22 +81,23 @@ static void all_accounts_del(u32 tid, int dir)
int target_del(u32 tid)
{
int err;
struct target* target;
struct target *target = target_find_by_id(tid);
int err = ki->target_destroy(tid);
if (!(target = target_find_by_id(tid)))
if (err < 0 && errno != ENOENT)
return -errno;
else if (!err && !target)
/* A leftover kernel object was cleaned up - don't complain. */
return 0;
if (!target)
return -ENOENT;
if (target->nr_sessions)
return -EBUSY;
if ((err = target_destroy(tid)) < 0)
return err;
remque(&target->tlist);
if (!list_empty(&target->sessions_list)) {
log_error("%s still have sessions %d\n", __func__, tid);
log_error("%s: target %u still has sessions\n", __FUNCTION__,
tid);
exit(-1);
}