netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Veaceslav Falico <vfalico@redhat.com>
To: Scott Feldman <sfeldma@cumulusnetworks.com>
Cc: Jay Vosburgh <fubar@us.ibm.com>,
	Andy Gospodarek <andy@greyhouse.net>,
	Netdev <netdev@vger.kernel.org>,
	Roopa Prabhu <roopa@cumulusnetworks.com>,
	Shrijeet Mukherjee <shm@cumulusnetworks.com>
Subject: Re: [PATCH net-next 1/2] bonding: add sysfs /slave dir for bond slave devices.
Date: Thu, 16 Jan 2014 19:40:30 +0100	[thread overview]
Message-ID: <20140116184030.GA24396@redhat.com> (raw)
In-Reply-To: <B1B4CB0E-6A3C-4023-9911-D57B5F58D691@cumulusnetworks.com>

On Thu, Jan 16, 2014 at 10:04:31AM -0800, Scott Feldman wrote:
>
>On Jan 16, 2014, at 7:31 AM, Veaceslav Falico <vfalico@redhat.com> wrote:
>
>> On Wed, Jan 15, 2014 at 09:54:34PM -0800, Scott Feldman wrote:
>>> Add sub-directory under /sys/class/net/<interface>/slave with
>>> read-only attributes for slave.  Directory only appears when
>>> <interface> is a slave.
>
>>> +static ssize_t state_show(struct slave *slave, char *buf)
>>> +{
>>> +	switch (bond_slave_state(slave)) {
>>> +	case BOND_STATE_ACTIVE:
>>> +		return sprintf(buf, "active\n");
>>> +	case BOND_STATE_BACKUP:
>>> +		return sprintf(buf, "backup\n");
>>> +	default:
>>> +		return sprintf(buf, "UNKONWN\n");
>>> +	}
>>> +}
>>> +static SLAVE_ATTR_RO(state);
>>
>> Am I missing something or does it really completely lacks any locking?
>>
>> What prevents the slave to be freed in between?
>
>Correct me if I’m wrong, but I think the equivalent question is: is there a race between sysfs_remove_file() and another CPU open on that file trying to read/write the file?  I believe the answer is no, but I’ll defer to the experts.
>
>The file removal call path is:
>
>	
>	bond_release (ndo_del_slave)
>		__bond_release_one
>			bond_sysfs_slave_del
>				sysfs_remove_file
>			<...continue freeing slave...>
>
>So slave is freed after sysfs_remove_file.  I would expect I/O on sysfs file to fail during sysfs_remove_file.
>
>Does this sound OK?  Am I missing anything else?

Yeah, totally, and as they're read-only there's no locking needed indeed.

>
>-scott
>		

  reply	other threads:[~2014-01-16 18:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-16  5:54 [PATCH net-next 1/2] bonding: add sysfs /slave dir for bond slave devices Scott Feldman
2014-01-16  8:04 ` Ding Tianhong
2014-01-16 15:31 ` Veaceslav Falico
2014-01-16 18:04   ` Scott Feldman
2014-01-16 18:40     ` Veaceslav Falico [this message]
2014-01-16 18:44 ` Veaceslav Falico
2014-01-16 19:00   ` Scott Feldman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140116184030.GA24396@redhat.com \
    --to=vfalico@redhat.com \
    --cc=andy@greyhouse.net \
    --cc=fubar@us.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@cumulusnetworks.com \
    --cc=sfeldma@cumulusnetworks.com \
    --cc=shm@cumulusnetworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).