From: Mike C. <mi...@us...> - 2005-04-07 21:27:11
|
Smitha Narayanaswamy (smithan) wrote: > Sorry! Here's the patch. > > -Smitha > > >>-----Original Message----- >>From: Smitha Narayanaswamy (smithan) [mailto:sm...@ci...] >>Sent: Thursday, April 07, 2005 3:50 PM >>To: 'linux-iscsi-devel' >>Subject: [linux-iscsi-devel] [PATCH] Connfailtimeout exported to > > sysfs > >>This patch is for the stabilization effort of the driver with 2.6.9 >>The patch exports connfailtimeout into sysfs. It was built >>over the 4-0 branch and "race_fix.patch" >> >>Thanks, >>Smitha >> > > > > > +static ssize_t > +store_replacement_timeout(struct class_device *class_dev, const char *buf, > + size_t count) > +{ > + struct Scsi_Host *shost = class_to_shost(class_dev); > + struct iscsi_session *session = (struct iscsi_session *)shost->hostdata; > + int timeout; > + > + sscanf(buf, "%d\n", &timeout); check your input? negative values? > + iscsi_update_replacement_timeout(session, timeout); > + return count; > +} > + > static CLASS_DEVICE_ATTR(shutdown, S_IWUSR, NULL, store_do_shutdown); > static CLASS_DEVICE_ATTR(drop_session, S_IWUSR, NULL, store_drop_session); > +static CLASS_DEVICE_ATTR(connfailtimeout, S_IWUSR, NULL, > + store_replacement_timeout); > > /* > * Macro to show session values specific to this driver > @@ -92,6 +107,7 @@ session_rd_time_attr(session_drop_time, > struct class_device_attribute *iscsi_host_attrs[] = { > &class_device_attr_shutdown, > &class_device_attr_drop_session, > + &class_device_attr_connfailtimeout, > &class_device_attr_session_established_time, > &class_device_attr_session_drop_time, > &class_device_attr_login_timeout, > diff -Naurp linux-iscsi/driver/iscsi-session.c linux-iscsi_cto/driver/iscsi-session.c > --- linux-iscsi/driver/iscsi-session.c 2005-04-07 13:03:57.000000000 +0530 > +++ linux-iscsi_cto/driver/iscsi-session.c 2005-04-07 15:06:00.000000000 +0530 > @@ -63,6 +63,28 @@ iscsi_drop_session(struct iscsi_session > signal_iscsi_threads(session); > } > > +void > +iscsi_update_replacement_timeout(struct iscsi_session *session, int timeout) > +{ > + spin_lock(&session->portal_lock); > + session->portal.replacement_timeout = why did we duplicate this timeout on the portal and session? I guess it does not matter for your patch if it is just leftovers from the stuff you guys were going to cleanup. > + session->replacement_timeout = timeout; > + spin_lock_bh(&session->task_lock); > + if ((test_bit(SESSION_ESTABLISHED, &session->control_bits)) || > + (test_bit(SESSION_REPLACEMENT_TIMEDOUT, &session->control_bits)) || > + !timeout) { > + spin_unlock_bh(&session->task_lock); > + spin_unlock(&session->portal_lock); > + return; > + } > + spin_unlock_bh(&session->task_lock); > + timeout *= HZ; > + session->replacement_timer.expires = jiffies + timeout; I am pretty sure you do not want touch "expires". mod_timer will do this for you. What happens if the timeout handler is running at this point. It then sets the SESSION_REPLACEMENT_TIMEDOUT bit, and here you mod_timer it and restart it right? Nothing bad happens except the timer will run again and when it fires the second time it will notice that bits from the previous run. Are you happy with this? Is the other alt to del_timer_sync then do a mod_timer? Was that why you are digging into expires? > + mod_timer(&session->replacement_timer, > + session->replacement_timer.expires); > + spin_unlock(&session->portal_lock); > +} > + > static void > handle_logout_timeouts(unsigned long data) > { > @@ -338,6 +360,9 @@ __establish_session(struct iscsi_session > goto done; > > iscsi_host_notice(session, "Session established\n"); > + spin_lock(&session->portal_lock); > + del_timer_sync(&session->replacement_timer); > + spin_unlock(&session->portal_lock); Don't need this here. You would accomplish the same thing by moving the session bit setting/clearing here right? You would then jsut have the one del timer below in iscsi_tx_thread. > /* > * logged in ok, get the new session ready > */ > @@ -1044,11 +1069,6 @@ iscsi_tx_thread(void *data) > struct iscsi_session *session = data; > int rc; > unsigned long tmo; > - struct timer_list replacement_timer; > - > - init_timer(&replacement_timer); > - replacement_timer.data = (unsigned long)session; > - replacement_timer.function = replacement_timed_out; > > current->flags |= PF_MEMALLOC; > allow_signal(SIGHUP); > @@ -1061,11 +1081,19 @@ iscsi_tx_thread(void *data) > up(&session->tx_blocked); > > while (!session_kthread_sleep(session)) { > + spin_lock(&session->portal_lock); > tmo = session->replacement_timeout * HZ; > - if (tmo && session->session_drop_time) > - mod_timer(&replacement_timer, jiffies + tmo); > + if (tmo && session->session_drop_time) { > + del_timer_sync(&session->replacement_timer); > + session->replacement_timer.expires = jiffies + tmo; same expires. > + mod_timer(&session->replacement_timer, > + session->replacement_timer.expires); > + } > + spin_unlock(&session->portal_lock); > rc = iscsi_wait_for_session(session, 1); > - del_timer_sync(&replacement_timer); > + spin_lock(&session->portal_lock); > + del_timer_sync(&session->replacement_timer); > + spin_unlock(&session->portal_lock); > if (!rc) > continue; > > @@ -1410,6 +1438,10 @@ iscsi_create_session(struct iscsi_sessio > rc = -ENOMEM; > goto free_session; > } > + > + init_timer(&session->replacement_timer); > + session->replacement_timer.data = (unsigned long)session; > + session->replacement_timer.function = replacement_timed_out; stick this with the other timers in start session threads > > rc = start_session_threads(session); > up(&session->config_mutex); > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > linux-iscsi-devel mailing list > lin...@li... > https://lists.sourceforge.net/lists/listinfo/linux-iscsi-devel > |