<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes"?>
<?rfc strict="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<!DOCTYPE rfc [
  <!ENTITY MAY "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MAY</bcp14>">
  <!ENTITY MUST "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST</bcp14>">
  <!ENTITY MUST-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST NOT</bcp14>">
  <!ENTITY OPTIONAL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>OPTIONAL</bcp14>">
  <!ENTITY RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>RECOMMENDED</bcp14>">
  <!ENTITY REQUIRED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>REQUIRED</bcp14>">
  <!ENTITY SHALL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL</bcp14>">
  <!ENTITY SHALL-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL NOT</bcp14>">
  <!ENTITY SHOULD "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD</bcp14>">
  <!ENTITY SHOULD-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD NOT</bcp14>">
]>
<rfc ipr="full3978" category="std" number="4331" xmlns:grddl='http://www.w3.org/2003/g/data-view#' grddl:transformation='rfc2629grddl.xslt' xmlns:x="http://purl.org/net/xml2rfc/ext">
    <front>
        <title abbrev="WebDAV Quotas">Quota and Size Properties for&#160;Distributed&#160;Authoring&#160;and&#160;Versioning&#160;(DAV)&#160;Collections</title>
        <author initials="B." surname="Korver" fullname="Brian Korver">
            <organization abbrev="Network Resonance">Network Resonance, Inc.</organization>
            <address>
                <postal>
                    <street>2483 E. Bayshore Road</street>
                    <street>Suite 212</street>
                    <city>Palo Alto</city>
                    <region>CA</region>
                    <code>94303</code>
                    <country>US</country>
                </postal>
                <phone>+1 650 812-7705</phone>
                <email>briank@networkresonance.com</email>
            </address>
        </author>
        <author initials="L." surname="Dusseault" fullname="Lisa Dusseault">
            <organization abbrev="OSAF">Open Source Applications Foundation</organization>
            <address>
                <postal>
                    <street>543 Howard Street</street>
                    <street>5th Floor</street>
                    <city>San Francisco</city>
                    <region>CA</region>
                    <code>94105</code>
                    <country>US</country>
                </postal>
                <phone>+1 415 946-3040</phone>
                <email>lisa@osafoundation.org</email>
            </address>
        </author>
        <date month="February" year="2006"/>
        <area>Applications</area>
        <workgroup>WWW Distributed Authoring and Versioning (webdav)</workgroup>
        <keyword>quota</keyword>
        <abstract>
            <t> Web Distributed Authoring and Versioning (WebDAV) servers are frequently deployed with quota (size) limitations. This
                document discusses the properties and minor behaviors needed for clients to
                interoperate with quota (size) implementations on WebDAV repositories.</t>
        </abstract>
    </front>
    <middle>
        <section anchor="intro" title="Introduction">
            <section anchor="notation" title="Notational Conventions">
                <t> The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
                    "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
                    interpreted as described in <xref target="RFC2119"/>.</t>
<t>
The definition of live property is provided in <xref target="RFC2518"/>.
The definition of protected and computed properties is provided in
<xref target="RFC3253" x:fmt="," x:sec="1.4"/>.
</t>
            </section>
            <section anchor="requirement" title="Requirement for Quotas">
                <t> WebDAV servers based on <xref target="RFC2518"/> have been implemented and
                    deployed with quota restrictions on collections and users, so it makes sense to
                    standardize this functionality to improve user experience and client
                    interoperability. 
</t>
                <t> The reasons why WebDAV servers frequently have quotas enforced are the same
                    reasons why any storage system comes with quotas. <vspace blankLines="0"/>
                    <list style="symbols">
                        <t> Sometimes the storage service charges according to quota. </t>
                        <t> Sometimes the storage service is provided free, but the storage service
                            provider has limited storage space (e.g., 
                            university-provided student accounts). </t>
                        <t> Even in cases where the storage can be upgraded, the storage managers
                            may choose to limit quota in order to encourage users to limit the files
                            they store on the system and to clean up obsolete files (e.g., IT
                            departments within corporations). </t>
                    </list>
                </t>
                <t> In order to work best with repositories that support quotas, client software
                    should be able to determine and display the DAV:quota-available-bytes 
                    (defined below) on collections.
                    Further, client software should have some way of fairly reliably determining how
                    much storage space is already counted towards that quota.</t>
            <t> Support for the properties defined in this document
                enhances the client experience, because the client has a chance of managing its files 
                to avoid
                running out of allocated storage space. Clients may not be able to calculate the
                value as accurately on their own, depending on how total space used is calculated by
                the server.</t>
            </section>
        </section>
        <section anchor="overview" title="Solution Overview">
            <t> The approach to meeting the requirements and scenarios outlined above is to define
                two live properties. This specification can be met on a server by implementing
                both DAV:quota-available-bytes and DAV:quota-used-bytes on collections only.</t>
            <t> A &lt;DAV:allprop&gt; PROPFIND request &SHOULD-NOT; return any of the properties
                defined by this document.
                However, these property names &MUST; be returned
                in a &lt;DAV:propname&gt; request for a resource that supports the
                properties, except in the case of infinite limits, which are explained below.</t>
            <t> The DAV:quota-available-bytes and DAV:quota-used-bytes definitions below borrow heavily from the quota
                definitions in the Network File System (NFS) <xref target="RFC3530"/> specification.</t>
        </section>
        <section anchor="quota-available-bytes" title="DAV:quota-available-bytes">
            <iref item="Properties" subitem="DAV:quota-available-bytes" primary="true"/>  
            <iref item="DAV:quota-available-bytes property" primary="true"/>  
            <t>
                <list style="hanging">
                    <t hangText="Name:">quota-available-bytes</t>
                    <t hangText="Namespace:">DAV:</t>
                    <t hangText="Purpose:">Indicates the maximum amount of additional storage
                        available to be allocated to a resource.</t>
                    <t hangText="DTD:">&lt;!ELEMENT quota-available-bytes (#PCDATA) &gt;</t>
                </list>
            </t>
            <t> The DAV:quota-available-bytes property value is the value in octets representing the
                amount of additional disk space beyond the current allocation that can be allocated
                to this resource before further allocations will be refused. It is
                understood that this space may be consumed by allocations to other resources.</t>
            <t> Support for this property is &REQUIRED; on collections, and &OPTIONAL; on other
                resources. A server &SHOULD; implement this property for each resource that has the
                DAV:quota-used-bytes property.</t>
            <t> Clients &SHOULD; expect that as the DAV:quota-available-bytes on a resource approaches
                0, further allocations to that resource may be refused. A value of 0
                indicates that users will probably not be able to perform operations that write
                additional information (e.g., a PUT inside a collection), but may be able to replace
                through overwrite an existing resource of equal size.</t>
            <t> Note that there may be a number of distinct but overlapping limits, which may even
                include physical media limits. When reporting DAV:quota-available-bytes, the server is at
                liberty to choose any of those limits but &SHOULD; do so in a repeatable way. The rule
                may be configured per repository, or may be "choose the smallest number".</t>
            <t> If a resource has no quota enforced or unlimited storage ("infinite limits"), the
                server &MAY; choose not to return this property (404 Not Found response in
                Multi-Status), although this specification RECOMMENDS that servers return some
                appropriate value (e.g., the amount of free disk space). A client cannot entirely
                assume that there is no quota enforced on a resource that does not have this
                property, but might as well act as if there is no quota.</t>
            <t> The value of this property is protected (see <xref target="RFC3253" x:fmt="of" x:sec="1.4.2"/>
                for the definition of protected properties).  A 403 Forbidden response is &RECOMMENDED; for
                attempts to write a protected property, and the server &SHOULD; include an
                XML error body as defined by DeltaV <xref target="RFC3253"/> with the
                &lt;DAV:cannot-modify-protected-property/&gt; precondition tag.
  </t>
        </section>
        <section anchor="quota-used-bytes" title="DAV:quota-used-bytes">
            <iref item="Properties" subitem="DAV:quota-used-bytes" primary="true"/>  
            <iref item="DAV:quota-used-bytes property" primary="true"/>  
            <t>
                <list style="hanging">
                    <t hangText="Name:">quota-used-bytes</t>
                    <t hangText="Namespace:">DAV:</t>
                    <t hangText="Purpose:">Contains the amount of storage counted against the quota
                        on a resource.</t>
                    <t hangText="DTD:">&lt;!ELEMENT quota-used-bytes (#PCDATA) &gt;</t>
                </list>
            </t>
            <t> The DAV:quota-used-bytes value is the value in octets representing the amount of
                space used by this resource and possibly a number of other similar 
                resources, where the set of "similar" meets at least the criterion that allocating
                space to any resource in the set will count against the DAV:quota-available-bytes.
                It &MUST; include the total count including usage derived from sub-resources if
                appropriate. It &SHOULD; include metadata storage size if metadata storage is counted
                against the DAV:quota-available-bytes.</t>
            <t> Note that there may be a number of distinct but overlapping sets of
                resources for which a DAV:quota-used-bytes is maintained (e.g., "all files with a given
                owner", "all files with a given group owner", etc.). The server is at liberty to
                choose any of those sets but &SHOULD; do so in a repeatable way. The rule may be
                configured per repository.</t>
            <t> Support for this property is &REQUIRED; on collections, and &OPTIONAL; on other
                resources. A server &SHOULD; implement this property for each resource that has the
                DAV:quota-available-bytes property.</t>
<t>
This value of this property is computed (see <xref target="RFC3253" x:fmt="of" x:sec="1.4.3"/> for
the definition of computed property).  A 403 Forbidden response is
&RECOMMENDED; for attempts to write a protected property, and the server
&SHOULD; include an XML error body as defined by DeltaV
<xref target="RFC3253"/> with the
&lt;DAV:cannot-modify-protected-property/&gt; precondition tag.
</t>
        </section>

        <section anchor="example-propfind" title="Example PROPFIND Request and Response">
            <figure>
                <preamble>Request:</preamble>
                <artwork type='message/http; msgtype="request"'
><![CDATA[      PROPFIND /~milele/public/ HTTP/1.1
      Depth: 0
      Host: www.example.com
      Content-Type: text/xml
      Content-Length: xxx

      <?xml version="1.0" ?>
      <D:propfind xmlns:D="DAV:">
        <D:prop>
          <D:quota-available-bytes/>
          <D:quota-used-bytes/>
        </D:prop>
      </D:propfind>]]></artwork>
            </figure><figure>
                <preamble>Response:</preamble>
                <artwork type='message/http; msgtype="response"'
><![CDATA[      HTTP/1.1 207 Multi-Status
      Date: Tue, 16 Oct 2001 22:13:39 GMT
      Content-Length: xxx
      Content-Type: text/xml; charset=UTF-8

      <?xml version="1.0" encoding="utf-8" ?>
      <D:multistatus xmlns:D="DAV:">
      <D:response>
        <D:href>http://www.example.com/~milele/public/</D:href>
        <D:propstat>
          <D:prop>
            <D:quota-available-bytes>596650</D:quota-available-bytes>
            <D:quota-used-bytes>403350</D:quota-used-bytes>
          </D:prop>
          <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
      </D:response>
      </D:multistatus>]]></artwork>
            </figure>
        </section>
        <section anchor="errors" title="Error Reporting">
            <t> WebDAV <xref target="RFC2518"/> defines the status code 507 (Insufficient Storage).
                This status code &SHOULD; be used when a client request (e.g., a PUT, PROPFIND, MKCOL,
                MOVE, or COPY) fails because it would exceed their quota or physical storage limits.
In order to
                differentiate the response from other storage problems, the server &SHOULD; include an
                XML error body as defined by DeltaV <xref target="RFC3253"/> with the
                appropriate precondition tag.
</t>
<t>Preconditions:</t>
<t>
  <iref item="Condition Names" subitem="DAV:quota-not-exceeded (pre)" primary="true"/> 
  <iref item="DAV:quota-not-exceeded precondition" primary="true"/> 
  (DAV:quota-not-exceeded): the request &MUST-NOT; cause the allocated
  quota to be exceeded.
</t>
<t>
  <iref item="Condition Names" subitem="DAV:sufficient-disk-space (pre)" primary="true"/> 
  <iref item="DAV:sufficient-disk-space precondition" primary="true"/> 
  (DAV:sufficient-disk-space):  there is sufficient physical space to
  execute the request.
</t>
            <figure>
                <preamble> Example error response:</preamble>
                <artwork type='message/http; msgtype="response"'><![CDATA[
   HTTP/1.1 507 Insufficient Storage
   Content-Length: xxx
   Content-Type: text/xml

   <?xml version="1.0">
   <error xmlns="DAV:">
     <quota-not-exceeded/>
   </error>
]]></artwork>
            </figure>
<t>
Implementation note: some clients may be able to take advantage of the different precondition codes when mapping to operating system status codes, such as E_NOSPC and E_DQUOT in NFS (see <xref target="RFC3530" x:fmt="," x:sec="12"/>).
</t>
        </section>
        <section anchor="Notes" title="Notes">
            <t> Server implementations store and account for their data in many different ways. Some
                of the challenges: <vspace blankLines="0"/>
                <list style="symbols">
                    <t> Some server implementations find it prohibitive to count storage used for
                        metadata; others may choose to do so for better accounting.</t>
                    <t> Older versions of resources may be stored as well.</t>
                    <t> Variants of one resource may exist with different content lengths.</t>
                    <t> Content may be dynamically generated.</t>
                    <t> Resource bodies can be compressed.</t>
                    <t> Some resources may be stored for "free", not counting against quota.</t>
                </list>
            </t>
            <t> Since server storage accounting can vary so much, clients should expect the
                following: <vspace blankLines="0"/>
                <list style="symbols">
                    <t> The size of a file on the client's file system, or in a PUT message, may not
                        correspond to the amount of storage required by the server to store the
                        resource. Thus, the client cannot predict with 100% accuracy whether a given
                        file will be allowed given the storage quota.</t>
                    <t> Deleting or overwriting a resource may not free up the same amount of
                        storage as indicated by the DAV:getcontentlength property defined in <xref
                        target="RFC2518"/> for the resource. If deleting a resource does not free up
                        any space, the file may have been moved to a "trash" folder or "recycle
                        bin", or retained as in versioning systems (<xref target="RFC3253"/>).</t>

<t>
Since there are many factors that affect the storage used by a set of
resources, including automatic compression, the size of associated metadata,
and server-inserted content (such as that created by PHP code) in the
on-the-wire representation of resources, clients are advised not to depend
on the value of DAV:quota-used-bytes being the sum of the
DAV:getcontentlength properties for resources contained by a collection.
</t>
<t>
Additionally, because there may be a number of distinct but overlapping sets
of resources for which a DAV:quota-used-bytes is maintained
(<xref target="quota-used-bytes"/>),
there may be no correlation between the size of the resources in a
collection and DAV:quota-used-bytes. For example, for a server that implements
user-based quotas, DAV:quota-used-bytes usually will be the same for a
collection and it's members.
</t>
                    <t> On some systems where quota is counted by collection and not by user, a
                        quota on a sub-collection may be larger than the quota on the parent
                        collection that contains it. For example, the quota on /~milele/ may be 100
                        MB, but the quota on /~milele/public/ may be unlimited. This allows the
                        space used by /~milele/public/ to be as large as the quota on /~milele/
                        allows (depending on the other contents of /~milele/) even if the quota on
                        /~milele/ is changed. Thus, even when the quota on a parent collection is
                        changed, it is not necessarily required to change the quota on every child
                        or descendant collection.</t>
                </list>
            </t>
        </section>
        <section anchor="Security" title="Security Considerations">
            <t> A hacker may prefer to store files in collections with a large quota. This isn't
                strictly a security concern because it doesn't make it any easier to store files. On
                the other hand, the DAV:quota-used-bytes property may make it easier to detect
                tampering or misuse.</t>
        </section>
        <section anchor="Internationalization" title="Internationalization Considerations">
            <t> Quota is counted in Arabic numerals expressed in strings. There are no
                internationalization considerations. </t>
        </section>
        <section anchor="Acknowledgements" title="Acknowledgements">
            <t> Stefan Eissing, Geoff Clemm, Jim Luther, Julian Reschke, and Jim Whitehead, among others, have
                provided valuable comments on this document.</t>
        </section>
    </middle>
    <back>
        <references title="Normative References">
            <reference anchor="RFC2119">
                <front>
                    <title> Key words for use in RFCs to Indicate Requirement Levels</title>
                    <author initials="S." surname="Bradner" fullname="Scott Bradner">
                        <organization>Harvard University</organization>
                    </author>
                    <date month="March" year="1997"/>
                </front>
                <seriesInfo name="BCP" value="14"/>
                <seriesInfo name="RFC" value="2119"/>
            </reference>
            <reference anchor="RFC3253">
                <front>
                    <title> Versioning Extensions to WebDAV (Web Distributed Authoring and Versioning)</title>
                    <author initials="G." surname="Clemm">
                        <organization>Rational Software</organization>
                    </author>
                    <author initials="J." surname="Amsden">
                        <organization>IBM</organization>
                    </author>
                    <author initials="T." surname="Ellison">
                        <organization>IBM</organization>
                    </author>
                    <author initials="C." surname="Kaler">
                        <organization>Microsoft</organization>
                    </author>
                    <author initials="J." surname="Whitehead">
                        <organization>U.C. Santa Cruz</organization>
                    </author>
                    <date month="March" year="2002"/>
                </front>
                <seriesInfo name="RFC" value="3253"/>
            </reference>
            <reference anchor="RFC2518">
                <front>
                    <title>HTTP Extensions for Distributed Authoring -- WebDAV</title>
                    <author initials="Y." surname="Goland">
                        <organization/>
                    </author>
                    <author initials="E." surname="Whitehead">
                        <organization/>
                    </author>
                    <author initials="A." surname="Faizi">
                        <organization/>
                    </author>
                    <author initials="S." surname="Carter">
                        <organization/>
                    </author>
                    <author initials="D." surname="Jensen">
                        <organization/>
                    </author>
                    <date month="February" year="1999"/>
                </front>
                <seriesInfo name="RFC" value="2518"/>
            </reference>
        </references>
        <references title="Informative References">
            <reference anchor="RFC3530">
                <front>
                    <title>Network File System (NFS) version 4 Protocol</title>
                    <author initials="S." surname="Shepler">
                        <organization/>
                    </author>
                    <author initials="B." surname="Callaghan">
                        <organization/>
                    </author>
                    <author initials="D." surname="Robinson">
                        <organization/>
                    </author>
                    <author initials="R." surname="Thurlow">
                        <organization/>
                    </author>
                    <author initials="C." surname="Beame">
                        <organization/>
                    </author>
                    <author initials="M." surname="Eisler">
                        <organization/>
                    </author>
                    <author initials="D." surname="Noveck">
                        <organization/>
                    </author>
                    <date month="April" year="2003"/>
                </front>
                <seriesInfo name="RFC" value="3530"/>
            </reference>
        </references>
    </back>
</rfc>
